> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getclaro.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Background Jobs

> Queue scraping work and inspect or retry background jobs.

<Note>
  Authenticate every request with `Authorization: Bearer clr_live_YOUR_API_KEY`.
</Note>

## Queue a scrape

<Badge color="blue">POST</Badge> `/scrape`

Queue a scrape through the Claro Public API.

**Required scope:** `generate`

### Request body

Content type: `application/json` (required)

```json Request example theme={null}
{
  "urls": [
    "https://example.com/products"
  ],
  "prompt": "Extract product names and prices"
}
```

### Example request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://platform.getclaro.ai/api/public/v1/scrape" \
    -H "Authorization: Bearer clr_live_YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    --data '{
    "urls": [
      "https://example.com/products"
    ],
    "prompt": "Extract product names and prices"
  }'
  ```

  ```python Python theme={null}
  import json
  import requests
  url = f"https://platform.getclaro.ai/api/public/v1/scrape"
  headers = {"Authorization": "Bearer clr_live_YOUR_API_KEY"}
  payload = json.loads(r'''{
    "urls": [
      "https://example.com/products"
    ],
    "prompt": "Extract product names and prices"
  }''')
  response = requests.post(url, headers=headers, json=payload)
  response.raise_for_status()
  print(response.text)
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(`https://platform.getclaro.ai/api/public/v1/scrape`, {
    method: "POST",
    headers: {
      Authorization: "Bearer clr_live_YOUR_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      "urls": [
        "https://example.com/products"
      ],
      "prompt": "Extract product names and prices"
    }),
  });

  if (!response.ok) throw new Error(await response.text());
  const data = await response.json();
  ```
</CodeGroup>

### Responses

* `200` - Successful response
* `Default` - Error response. Rate-limited responses use HTTP 429.

***

## Get job by ID

<Badge color="green">GET</Badge> `/jobs`

Get job by ID through the Claro Public API.

**Required scope:** `generate`

### Parameters

| Name | Location | Type   | Required |
| ---- | -------- | ------ | -------- |
| `id` | query    | string | Yes      |

### Example request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://platform.getclaro.ai/api/public/v1/jobs?id=YOUR_ID" \
    -H "Authorization: Bearer clr_live_YOUR_API_KEY"
  ```

  ```python Python theme={null}
  import requests
  url = f"https://platform.getclaro.ai/api/public/v1/jobs?id=YOUR_ID"
  headers = {"Authorization": "Bearer clr_live_YOUR_API_KEY"}
  response = requests.get(url, headers=headers)
  response.raise_for_status()
  print(response.text)
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(`https://platform.getclaro.ai/api/public/v1/jobs?id=YOUR_ID`, {
    method: "GET",
    headers: {
      Authorization: "Bearer clr_live_YOUR_API_KEY",
    },
  });

  if (!response.ok) throw new Error(await response.text());
  const data = await response.json();
  ```
</CodeGroup>

### Responses

* `200` - Successful response
* `Default` - Error response. Rate-limited responses use HTTP 429.

***

## Get jobs by reference

<Badge color="green">GET</Badge> `/jobs/by-reference`

Get jobs by reference through the Claro Public API.

**Required scope:** `generate`

### Parameters

| Name            | Location | Type   | Required |
| --------------- | -------- | ------ | -------- |
| `referenceType` | query    | string | Yes      |
| `referenceId`   | query    | string | Yes      |

### Example request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://platform.getclaro.ai/api/public/v1/jobs/by-reference?referenceType=YOUR_REFERENCE_TYPE&referenceId=YOUR_REFERENCE_ID" \
    -H "Authorization: Bearer clr_live_YOUR_API_KEY"
  ```

  ```python Python theme={null}
  import requests
  url = f"https://platform.getclaro.ai/api/public/v1/jobs/by-reference?referenceType=YOUR_REFERENCE_TYPE&referenceId=YOUR_REFERENCE_ID"
  headers = {"Authorization": "Bearer clr_live_YOUR_API_KEY"}
  response = requests.get(url, headers=headers)
  response.raise_for_status()
  print(response.text)
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(`https://platform.getclaro.ai/api/public/v1/jobs/by-reference?referenceType=YOUR_REFERENCE_TYPE&referenceId=YOUR_REFERENCE_ID`, {
    method: "GET",
    headers: {
      Authorization: "Bearer clr_live_YOUR_API_KEY",
    },
  });

  if (!response.ok) throw new Error(await response.text());
  const data = await response.json();
  ```
</CodeGroup>

### Responses

* `200` - Successful response
* `Default` - Error response. Rate-limited responses use HTTP 429.

***

## Retry a job

<Badge color="blue">POST</Badge> `/jobs/retry`

Retry a job through the Claro Public API.

**Required scope:** `generate`

### Request body

Content type: `application/json` (required)

```json Request example theme={null}
{
  "backgroundTaskId": "00000000-0000-4000-8000-000000000009"
}
```

### Example request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://platform.getclaro.ai/api/public/v1/jobs/retry" \
    -H "Authorization: Bearer clr_live_YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    --data '{
    "backgroundTaskId": "00000000-0000-4000-8000-000000000009"
  }'
  ```

  ```python Python theme={null}
  import json
  import requests
  url = f"https://platform.getclaro.ai/api/public/v1/jobs/retry"
  headers = {"Authorization": "Bearer clr_live_YOUR_API_KEY"}
  payload = json.loads(r'''{
    "backgroundTaskId": "00000000-0000-4000-8000-000000000009"
  }''')
  response = requests.post(url, headers=headers, json=payload)
  response.raise_for_status()
  print(response.text)
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(`https://platform.getclaro.ai/api/public/v1/jobs/retry`, {
    method: "POST",
    headers: {
      Authorization: "Bearer clr_live_YOUR_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      "backgroundTaskId": "00000000-0000-4000-8000-000000000009"
    }),
  });

  if (!response.ok) throw new Error(await response.text());
  const data = await response.json();
  ```
</CodeGroup>

### Responses

* `200` - Successful response
* `Default` - Error response. Rate-limited responses use HTTP 429.
