# Store jobs

> Publish, sync, unpublish or republish a product on your connected stores, or send a change again, as the store buttons of the app do, and follow each job until it ends.

Source: https://docs.b7r.app/store-jobs

A store job is what a store button of the app does on one product and one store: `publish` puts the product on the store, `sync` sends its current state again, `unpublish` hides it there (the app calls it Disconnect), `republish` shows a hidden product again (Reconnect). `resend_issue` sends again a change a store did not take (from `GET /v1/store-issues`). A store can take longer to answer than a call may wait, so the call answers `202` with one job a store at once, and B7R does the work after it.

- Starting jobs needs `stores:publish`; reading them needs `stores:read`, which `stores:publish` goes with.
- One product and one store hold one open job at a time, from the app or the API. The same action again answers the job already open (you join it). Another action is refused for that store with `store_job_open` until the open one ends.
- A `publish` of a product already on that store, shown or hidden, is `done` with nothing changed. To show a hidden one, use `republish`.
- A person in the app is never queued behind a key: pressing a store button while your job only waits takes its place, and your job ends `failed` with `superseded_by_app`.
- A job is tried up to 4 times: the first, then after 1, 5 and 15 minutes, while the cause can pass (the store or the integration did not answer, the photos of a new product are still being drawn). A cause a retry cannot change ends it at once.
- Each try checks again that the key is still valid and holds `stores:publish`, and that the product and the store are yours. A key revoked while its jobs wait sends nothing.
- Follow a job without asking: with [updates](https://docs.b7r.app/updates) on, each job ends with one `product.store_changed` carrying its `job_id`: a publish, unpublish or republish with where the product now stands on the store (`published`, `hidden` or `removed`, even when it was there already), a sync or a resend with `synced`, and a job that fails with `failed` and its `reason`. A sync that re-creates a product the store deleted also sends `removed` and `published`. The update needs a key holding `stores:read`.
- By default your account runs at most 2 jobs at once and holds at most 50 open jobs; `GET /v1/me?include=limits` shows your values. Starting jobs is also limited per minute (`store_actions_per_minute`) and per day (`store_jobs_per_day`, from midnight Riyadh time). When several accounts wait, the account with the fewest jobs running goes first.

## Start store jobs

`POST /v1/store-jobs`

Name one action, one product and 1 to 20 stores, or `resend_issue` and one `issue_id`. Send an `Idempotency-Key`: the same key and body answer the same jobs again.

Before any job is made, the product and every store must be yours (else `404 not_found`), the product not taken down (`422 design_rejected` with `design_taken_down`) and, except for `unpublish`, not archived (`409 product_not_editable`).

Each store is then its own job, and a store refused does not undo the others. This example names three stores: the second is busy with another action, so the answer is `202` with two jobs and that store in `refused`, with the job that holds it (`job_id` is `null` when the store is busy with an action in the app). Every store you name is in `jobs` or in `refused`. A store or a product removed while the call ran is in `refused` with `not_found`. Only a call that got no job at all answers an error: `404 not_found`, `409 store_job_open`, or `429 rate_limited` with the error `queue_full` when your account holds its most open jobs. A call that would pass your daily number of jobs starts none: `429 rate_limited` with the error `daily_limit`.

Key: A key with the `stores:publish` area. Send `Idempotency-Key` and `Content-Type: application/json`.

Body:

- `action` (string, required): publish: put the product on the stores. sync: send its current state again. unpublish: hide it on the stores (the app's Disconnect). republish: show a hidden product again (the app's Reconnect). resend_issue: send again a change a store did not take. One of `publish`, `sync`, `unpublish`, `republish`, `resend_issue`.
- `product_id` (string (uuid)): A pair action: the product, from GET /v1/products.
- `store_ids` (array of string (uuid)): A pair action: 1 to 20 stores, from GET /v1/stores; one job each. 1 to 20 items.
- `issue_id` (string (uuid)): resend_issue: the issue, from GET /v1/store-issues.

Answer:

- `jobs` (array of object, required): One a store: a new job, or the open job of the same action, which this call joins.
  - `id` (string (uuid), required)
  - `action` (string, required): One of `publish`, `sync`, `unpublish`, `republish`, `resend_issue`.
  - `status` (string, required): queued: waiting for its turn or its next try. running: at the store now. done and failed are final. One of `queued`, `running`, `done`, `failed`.
  - `reason` (string or null, required): Why it failed, or why its last try did not finish (while queued); null when done.
  - `product_id` (string (uuid) or null, required)
  - `store_id` (string (uuid) or null, required)
  - `issue_id` (string (uuid) or null, required)
  - `attempts` (integer, required): Tries made so far; at most 4. At least 0.
  - `next_attempt_at` (string or null, required): When a queued job is tried next; null once it runs or ends.
  - `created_at` (string, required)
  - `updated_at` (string, required)
  - `finished_at` (string or null, required)
- `refused` (array of object, required)
  - `store_id` (string (uuid), required)
  - `code` (string, required): store_job_open: another action runs on this product and store now. queue_full: the account holds its most open store jobs. not_found: the store or the product went while the call ran. One of `store_job_open`, `queue_full`, `not_found`.
  - `job_id` (string (uuid) or null, required): The job of the other action that holds the pair; null for queue_full and not_found.

Errors: `unauthorized` (401), `area_forbidden` (403), `account_inactive` (403), `connection_disabled` (403), `https_required` (403), `not_found` (404), `invalid_request` (400), `idempotency_key_required` (400), `request_too_large` (413), `unsupported_media_type` (415), `rate_limited` (429), `internal_error` (500), `upstream_unavailable` (502), `api_unavailable` (503), `request_expired` (503), `service_unavailable` (503), `upstream_timeout` (504), `idempotency_mismatch` (409), `idempotency_in_flight` (409), `design_rejected` (422), `product_not_editable` (409), `try_again_later` (503), `store_job_open` (409). See [Errors](https://docs.b7r.app/errors).

Request:

```bash
curl -X POST https://api.b7r.app/v1/store-jobs \
  -H "Authorization: Bearer $B7R_API_KEY" \
  -H "Idempotency-Key: $(uuidgen 2>/dev/null || node -e 'console.log(crypto.randomUUID())')" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "publish",
    "product_id": "7f3c2a10-5b9e-4d6a-8c21-3e4f5a6b7c8d",
    "store_ids": [
      "1a2b3c4d-1111-4a5b-8c6d-7e8f9a0b1c2d",
      "1a2b3c4d-2222-4a5b-8c6d-7e8f9a0b1c2d",
      "1a2b3c4d-3333-4a5b-8c6d-7e8f9a0b1c2d"
    ]
  }'
```

```javascript
const res = await fetch("https://api.b7r.app/v1/store-jobs", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.B7R_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "action": "publish",
    "product_id": "7f3c2a10-5b9e-4d6a-8c21-3e4f5a6b7c8d",
    "store_ids": [
      "1a2b3c4d-1111-4a5b-8c6d-7e8f9a0b1c2d",
      "1a2b3c4d-2222-4a5b-8c6d-7e8f9a0b1c2d",
      "1a2b3c4d-3333-4a5b-8c6d-7e8f9a0b1c2d"
    ]
  }),
});
const data = await res.json();
```

```python
import os, requests, uuid

res = requests.post(
    "https://api.b7r.app/v1/store-jobs",
    headers={
        "Authorization": f"Bearer {os.environ['B7R_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "action": "publish",
        "product_id": "7f3c2a10-5b9e-4d6a-8c21-3e4f5a6b7c8d",
        "store_ids": [
            "1a2b3c4d-1111-4a5b-8c6d-7e8f9a0b1c2d",
            "1a2b3c4d-2222-4a5b-8c6d-7e8f9a0b1c2d",
            "1a2b3c4d-3333-4a5b-8c6d-7e8f9a0b1c2d"
        ]
    },
    timeout=30,
)
data = res.json()
```

Answer (202 Accepted):

```json
{
  "jobs": [
    {
      "id": "b1c2d3e4-0001-4f5a-8b6c-7d8e9f0a1b2c",
      "action": "publish",
      "status": "queued",
      "reason": null,
      "product_id": "7f3c2a10-5b9e-4d6a-8c21-3e4f5a6b7c8d",
      "store_id": "1a2b3c4d-1111-4a5b-8c6d-7e8f9a0b1c2d",
      "issue_id": null,
      "attempts": 0,
      "next_attempt_at": "2026-11-26T09:00:00.000Z",
      "created_at": "2026-11-26T09:00:00.000Z",
      "updated_at": "2026-11-26T09:00:00.000Z",
      "finished_at": null
    },
    {
      "id": "b1c2d3e4-0002-4f5a-8b6c-7d8e9f0a1b2c",
      "action": "publish",
      "status": "queued",
      "reason": null,
      "product_id": "7f3c2a10-5b9e-4d6a-8c21-3e4f5a6b7c8d",
      "store_id": "1a2b3c4d-3333-4a5b-8c6d-7e8f9a0b1c2d",
      "issue_id": null,
      "attempts": 0,
      "next_attempt_at": "2026-11-26T09:00:00.000Z",
      "created_at": "2026-11-26T09:00:00.000Z",
      "updated_at": "2026-11-26T09:00:00.000Z",
      "finished_at": null
    }
  ],
  "refused": [
    {
      "store_id": "1a2b3c4d-2222-4a5b-8c6d-7e8f9a0b1c2d",
      "code": "store_job_open",
      "job_id": "b1c2d3e4-0009-4f5a-8b6c-7d8e9f0a1b2c"
    }
  ]
}
```

## Read a store job

`GET /v1/store-jobs/{id}`

`status` is `queued`, `running`, `done` or `failed`; `done` and `failed` are final. A queued job shows when it is tried next, and the `reason` of its last try when one did not finish.

Another account’s job answers `404 not_found`, exactly like a job that does not exist.

Key: A key with the `stores:read` area.

Path:

- `id` (string (uuid), required)

Answer:

- `id` (string (uuid), required)
- `action` (string, required): One of `publish`, `sync`, `unpublish`, `republish`, `resend_issue`.
- `status` (string, required): queued: waiting for its turn or its next try. running: at the store now. done and failed are final. One of `queued`, `running`, `done`, `failed`.
- `reason` (string or null, required): Why it failed, or why its last try did not finish (while queued); null when done.
- `product_id` (string (uuid) or null, required)
- `store_id` (string (uuid) or null, required)
- `issue_id` (string (uuid) or null, required)
- `attempts` (integer, required): Tries made so far; at most 4. At least 0.
- `next_attempt_at` (string or null, required): When a queued job is tried next; null once it runs or ends.
- `created_at` (string, required)
- `updated_at` (string, required)
- `finished_at` (string or null, required)

Errors: `unauthorized` (401), `area_forbidden` (403), `account_inactive` (403), `connection_disabled` (403), `https_required` (403), `not_found` (404), `invalid_request` (400), `rate_limited` (429), `internal_error` (500), `upstream_unavailable` (502), `api_unavailable` (503), `request_expired` (503), `service_unavailable` (503), `upstream_timeout` (504). See [Errors](https://docs.b7r.app/errors).

Request:

```bash
curl https://api.b7r.app/v1/store-jobs/b1c2d3e4-0001-4f5a-8b6c-7d8e9f0a1b2c \
  -H "Authorization: Bearer $B7R_API_KEY"
```

```javascript
const res = await fetch("https://api.b7r.app/v1/store-jobs/b1c2d3e4-0001-4f5a-8b6c-7d8e9f0a1b2c", {
  headers: {
    Authorization: `Bearer ${process.env.B7R_API_KEY}`,
  },
});
const data = await res.json();
```

```python
import os, requests

res = requests.get(
    "https://api.b7r.app/v1/store-jobs/b1c2d3e4-0001-4f5a-8b6c-7d8e9f0a1b2c",
    headers={
        "Authorization": f"Bearer {os.environ['B7R_API_KEY']}",
    },
    timeout=30,
)
data = res.json()
```

Answer (200 OK):

```json
{
  "id": "b1c2d3e4-0001-4f5a-8b6c-7d8e9f0a1b2c",
  "action": "publish",
  "status": "done",
  "reason": null,
  "product_id": "7f3c2a10-5b9e-4d6a-8c21-3e4f5a6b7c8d",
  "store_id": "1a2b3c4d-1111-4a5b-8c6d-7e8f9a0b1c2d",
  "issue_id": null,
  "attempts": 1,
  "next_attempt_at": null,
  "created_at": "2026-11-26T09:00:00.000Z",
  "updated_at": "2026-11-26T09:00:07.214Z",
  "finished_at": "2026-11-26T09:00:07.214Z"
}
```

## List store jobs

`GET /v1/store-jobs`

Newest first. Filter by `product_id`, `store_id` or `status`. Page with `cursor` until `next_cursor` is `null`. A finished job stays listed for the days of your request log.

Key: A key with the `stores:read` area.

Query:

- `limit` (string)
- `cursor` (string): 1 to 256.
- `product_id` (string (uuid))
- `store_id` (string (uuid))
- `status` (string): One of `queued`, `running`, `done`, `failed`.

Answer:

- `data` (array of object, required)
  - `id` (string (uuid), required)
  - `action` (string, required): One of `publish`, `sync`, `unpublish`, `republish`, `resend_issue`.
  - `status` (string, required): queued: waiting for its turn or its next try. running: at the store now. done and failed are final. One of `queued`, `running`, `done`, `failed`.
  - `reason` (string or null, required): Why it failed, or why its last try did not finish (while queued); null when done.
  - `product_id` (string (uuid) or null, required)
  - `store_id` (string (uuid) or null, required)
  - `issue_id` (string (uuid) or null, required)
  - `attempts` (integer, required): Tries made so far; at most 4. At least 0.
  - `next_attempt_at` (string or null, required): When a queued job is tried next; null once it runs or ends.
  - `created_at` (string, required)
  - `updated_at` (string, required)
  - `finished_at` (string or null, required)
- `next_cursor` (string or null, required)

Errors: `unauthorized` (401), `area_forbidden` (403), `account_inactive` (403), `connection_disabled` (403), `https_required` (403), `invalid_request` (400), `rate_limited` (429), `internal_error` (500), `upstream_unavailable` (502), `api_unavailable` (503), `request_expired` (503), `service_unavailable` (503), `upstream_timeout` (504). See [Errors](https://docs.b7r.app/errors).

Request:

```bash
curl "https://api.b7r.app/v1/store-jobs?product_id=7f3c2a10-5b9e-4d6a-8c21-3e4f5a6b7c8d&status=failed" \
  -H "Authorization: Bearer $B7R_API_KEY"
```

```javascript
const res = await fetch("https://api.b7r.app/v1/store-jobs?product_id=7f3c2a10-5b9e-4d6a-8c21-3e4f5a6b7c8d&status=failed", {
  headers: {
    Authorization: `Bearer ${process.env.B7R_API_KEY}`,
  },
});
const data = await res.json();
```

```python
import os, requests

res = requests.get(
    "https://api.b7r.app/v1/store-jobs?product_id=7f3c2a10-5b9e-4d6a-8c21-3e4f5a6b7c8d&status=failed",
    headers={
        "Authorization": f"Bearer {os.environ['B7R_API_KEY']}",
    },
    timeout=30,
)
data = res.json()
```

Answer (200 OK):

```json
{
  "data": [
    {
      "id": "b1c2d3e4-0002-4f5a-8b6c-7d8e9f0a1b2c",
      "action": "publish",
      "status": "failed",
      "reason": "subscription_inactive",
      "product_id": "7f3c2a10-5b9e-4d6a-8c21-3e4f5a6b7c8d",
      "store_id": "1a2b3c4d-3333-4a5b-8c6d-7e8f9a0b1c2d",
      "issue_id": null,
      "attempts": 1,
      "next_attempt_at": null,
      "created_at": "2026-11-26T09:00:00.000Z",
      "updated_at": "2026-11-26T09:00:05.880Z",
      "finished_at": "2026-11-26T09:00:05.880Z"
    }
  ],
  "next_cursor": null
}
```

## Why a job failed

| `reason` | What happened |
| --- | --- |
| `not_found` | The product, the store or the issue is not yours, or is gone. A disconnect, in the app or with `POST /v1/stores/{id}/disconnect`, does not end the store’s waiting jobs at once: each fails when it comes to run, a product job with `not_found`. |
| `taken_down` | The design was taken down; it is never published or changed on a store. |
| `not_published` | A sync of a product that is not on that store: publish it first. |
| `not_unpublished` | A republish of a product that is not hidden on that store. |
| `platform_paused` | B7R paused that store platform's integration for a while. |
| `subscription_inactive` | The store's subscription to the B7R app lapsed. An unpublish still runs. |
| `store_rejected` | The store refused the product or the change. |
| `store_disconnected` | The store holds no valid connection to B7R: reconnect it in the app. |
| `sku_taken` | A SKU of the product belongs to another product on that store. |
| `admin_only` | Only B7R sends this change (the shipping company of an order). |
| `store_unavailable` | The store or the integration did not answer, on the last try. |
| `no_photos_yet` | The product's photos were still being drawn, on the last try. |
| `unlinked` | The store had deleted the product and it could not be made again, on the last try. Publish it. |
| `superseded_by_app` | Someone pressed a store button in the app for this product and store while the job waited. |
| `interrupted` | The job stopped while it ran and was out of tries. |
| `attempts_exhausted` | The job waited past its last try. |
| `integration_off` | The Custom API was off when the job came to run. |
| `key_revoked`, `key_expired`, `area_missing` | The key that started the job is revoked, expired or no longer holds `stores:publish`. |
| `account_inactive`, `connection_disabled` | The account or its Custom API connection was off when the job came to run. |
| `lease_lost`, `internal_error` | Something failed on B7R’s side, on the last try. Start the job again. |

> To send a change a store did not take, start `resend_issue` with its `issue_id`: { "action": "resend_issue", "issue_id": "9e8d7c6b-5a4f-4e3d-9c2b-1a0f9e8d7c6b" }. A resolved issue, and the shipping company change of an order (B7R's alone), answer `400 invalid_request` at `/body/issue_id`. A product's issue is not sent again once the product is taken down (`422 design_rejected`, `design_taken_down`) or archived (`404 not_found`), except the hide of a product hidden on that store, which always goes.
