# Get job

Read progress of document generation, CRM imports or briefing work. A completed result identifies the generated file or affected record, or reports imported record counts. Results remain subject to current access. A job awaiting input must be continued in Brigg. Retrying a start command with the same idempotency key returns the same job.

POST https://api.brigg.app/v1/operations/workspace.GetJob

## Access & visibility

Allow `workspace.GetJob` on your API key.

**Acting member required.** Send `Brigg-Act-As` with an [approved member account ID](https://developer.brigg.app/authentication#member-delegation). The key supplies permissions; the member selects whose data is used.

The selected member must be active and approved by the credential. This selects whose private data is used; the credential supplies permissions. Private ownership and project boundaries still apply.

[Set up authentication](https://developer.brigg.app/authentication) · [Choose permissions](https://developer.brigg.app/permissions)

## Request fields

Send a JSON object with the following fields. Required fields must be included; omit optional fields you do not need.
| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `job_id` | string | Yes | ID returned by a supported start operation, such as FillWordTemplate or GenerateBrief. Keep the same approved acting member used to start it. At least 1 character. |

## Poll without starting duplicate work

Keep `job_id` from the operation that started the work and use the same acting member when polling. This endpoint reads supported document-generation, briefing and CRM-import jobs; it does not enumerate every internal task.

- `queued` or `running`: wait before polling again. `retry_at`, when present, is an earliest suggested timestamp in Unix milliseconds; it is not a duration.
- `awaiting_input`: the person must continue the task in Brigg. Polling or repeating the start command does not answer that question.
- `completed`: inspect `kind` and the fields in `result`. A document job returns a `file_id`; a brief job identifies a record, not the brief's body; a CRM import can report an imported count.
- `failed` or `cancelled`: stop automatic polling and inspect the returned error or the task in Brigg before starting a new action.

Results still require current access. A previously readable job can become unavailable after revocation or a change to the target's permissions.

## Response

Returns **200 OK** with a JSON body.
| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `job_id` | string | Yes | Opaque job identifier returned when the work starts. |
| `kind` | string | Yes | The work this job performs. Allowed: `"document_generation"`, `"crm_import"`, `"brief"`, `"brief_action"`. |
| `status` | string | Yes | Failed and cancelled are terminal. An automatically retried attempt remains queued. Awaiting_input needs a response in the task in Brigg; do not start duplicate work. Allowed: `"queued"`, `"running"`, `"awaiting_input"`, `"completed"`, `"failed"`, `"cancelled"`. |
| `created_at` | integer | Yes | Time the work was accepted, in Unix milliseconds. |
| `updated_at` | integer | Yes | Most recent progress change, in Unix milliseconds. |
| `retry_at` | integer or null | Yes | Earliest suggested next check, in Unix milliseconds, or null when no specific time is supplied. Still poll with a delay and honor HTTP rate limits. |
| `result` | [object](#response-result) or null | Yes | Completion result selected by kind. Null while unfinished or when no public result is available. A resource_id identifies a record; it is not generated content. |
| `error` | [object](#response-error) or null | Yes | A terminal failure. Fix the cause and submit a new command with a new idempotency key; retrying the old command returns the same job. |

### response.result

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `file_id` | string | No | Generated file; use documents.GetFileDownload. |
| `resource_type` | string | No | Kind of the affected record. |
| `resource_id` | string | No | Affected record identifier; read the record for current values. |
| `imported` | integer | No | Records created or updated. |

### response.error

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `code` | string | Yes | Machine-readable code identifying this outcome or issue. |
| `message` | string | Yes | Human-readable explanation of the returned outcome. |

## Errors & retries

This operation reads data. It needs no idempotency key and can be retried after a transient failure.

For rate limits, follow the server’s retry guidance and back off. See [HTTP errors](https://developer.brigg.app/http#errors) and [safe retries and limits](https://developer.brigg.app/reliability).

| HTTP status | Code | What to do |
| --- | --- | --- |
| 400 | `invalid_json` | Send a JSON object with Content-Type: application/json. |
| 400 | `invalid_input` | Check the request fields and types. |
| 401 | `invalid_key` | The workspace API key is missing, invalid or revoked. |
| 403 | `forbidden` | Check the key’s operation and resource grants. Supply Brigg-Act-As with a member authorized by the key’s delegation grant. The selected member must be active and approved by the credential. This selects whose private data is used; the credential supplies permissions. Private ownership and project boundaries still apply. |
| 404 | `not_found` | The requested operation or resource is not available to this credential. |
| 429 | `rate_limited` | Wait for Retry-After before retrying. |

## Next steps

- [Get file download](https://developer.brigg.app/reference/documents/GetFileDownload)
- [Get CRM import run](https://developer.brigg.app/reference/customers/GetCrmImportRun)
- [Fill Word template](https://developer.brigg.app/reference/documents/FillWordTemplate)

[Download OpenAPI](https://developer.brigg.app/openapi.json) · [Versioning & retirement](https://developer.brigg.app/versioning)

## Examples

### Still generating

No file exists in this result yet. Wait before polling again.
#### cURL


```sh
curl 'https://api.brigg.app/v1/operations/workspace.GetJob' \
  -H "Authorization: Bearer $BRIGG_API_KEY" \
  -H 'Content-Type: application/json' \
  -H "Brigg-Act-As: $BRIGG_ACT_AS" \
  --data-raw '{
  "job_id": "job_document_proposal"
}'
```

#### TypeScript


```typescript
const actAs = process.env.BRIGG_ACT_AS;
if (!actAs) throw new Error("Set BRIGG_ACT_AS to an approved member account ID.");

const response = await fetch("https://api.brigg.app/v1/operations/workspace.GetJob", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BRIGG_API_KEY}`,
    "Content-Type": "application/json",
    "Brigg-Act-As": actAs,
  },
  body: JSON.stringify({
    "job_id": "job_document_proposal"
  }),
});
const result = await response.json();
if (!response.ok) throw new Error(`${response.status}: ${result.error} — ${result.message}`);
console.log(result);
```

#### Python


```python
import json
import os
from urllib.request import Request, urlopen
from urllib.error import HTTPError

payload = {
  "job_id": "job_document_proposal"
}
request = Request(
    "https://api.brigg.app/v1/operations/workspace.GetJob",
    data=json.dumps(payload).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {os.environ['BRIGG_API_KEY']}",
        "Content-Type": "application/json",
        "Brigg-Act-As": os.environ["BRIGG_ACT_AS"],
    },
    method="POST",
)
try:
    with urlopen(request) as response:
        print(json.load(response))
except HTTPError as error:
    print(error.code, json.load(error))
    raise
```

#### Response example


```json
{
  "job_id": "job_document_proposal",
  "kind": "document_generation",
  "created_at": 1794301200000,
  "updated_at": 1794301260000,
  "retry_at": null,
  "result": null,
  "error": null,
  "status": "running"
}
```

### Document ready

Use the returned file_id with GetFileDownload. The job response contains no temporary download credential.
#### cURL


```sh
curl 'https://api.brigg.app/v1/operations/workspace.GetJob' \
  -H "Authorization: Bearer $BRIGG_API_KEY" \
  -H 'Content-Type: application/json' \
  -H "Brigg-Act-As: $BRIGG_ACT_AS" \
  --data-raw '{
  "job_id": "job_document_proposal"
}'
```

#### TypeScript


```typescript
const actAs = process.env.BRIGG_ACT_AS;
if (!actAs) throw new Error("Set BRIGG_ACT_AS to an approved member account ID.");

const response = await fetch("https://api.brigg.app/v1/operations/workspace.GetJob", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BRIGG_API_KEY}`,
    "Content-Type": "application/json",
    "Brigg-Act-As": actAs,
  },
  body: JSON.stringify({
    "job_id": "job_document_proposal"
  }),
});
const result = await response.json();
if (!response.ok) throw new Error(`${response.status}: ${result.error} — ${result.message}`);
console.log(result);
```

#### Python


```python
import json
import os
from urllib.request import Request, urlopen
from urllib.error import HTTPError

payload = {
  "job_id": "job_document_proposal"
}
request = Request(
    "https://api.brigg.app/v1/operations/workspace.GetJob",
    data=json.dumps(payload).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {os.environ['BRIGG_API_KEY']}",
        "Content-Type": "application/json",
        "Brigg-Act-As": os.environ["BRIGG_ACT_AS"],
    },
    method="POST",
)
try:
    with urlopen(request) as response:
        print(json.load(response))
except HTTPError as error:
    print(error.code, json.load(error))
    raise
```

#### Response example


```json
{
  "job_id": "job_document_proposal",
  "kind": "document_generation",
  "created_at": 1794301200000,
  "updated_at": 1794301260000,
  "retry_at": null,
  "result": {
    "file_id": "f_proposal"
  },
  "error": null,
  "status": "completed"
}
```

### Generation failed

A terminal failure requires inspection; do not keep polling indefinitely.
#### cURL


```sh
curl 'https://api.brigg.app/v1/operations/workspace.GetJob' \
  -H "Authorization: Bearer $BRIGG_API_KEY" \
  -H 'Content-Type: application/json' \
  -H "Brigg-Act-As: $BRIGG_ACT_AS" \
  --data-raw '{
  "job_id": "job_document_proposal"
}'
```

#### TypeScript


```typescript
const actAs = process.env.BRIGG_ACT_AS;
if (!actAs) throw new Error("Set BRIGG_ACT_AS to an approved member account ID.");

const response = await fetch("https://api.brigg.app/v1/operations/workspace.GetJob", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BRIGG_API_KEY}`,
    "Content-Type": "application/json",
    "Brigg-Act-As": actAs,
  },
  body: JSON.stringify({
    "job_id": "job_document_proposal"
  }),
});
const result = await response.json();
if (!response.ok) throw new Error(`${response.status}: ${result.error} — ${result.message}`);
console.log(result);
```

#### Python


```python
import json
import os
from urllib.request import Request, urlopen
from urllib.error import HTTPError

payload = {
  "job_id": "job_document_proposal"
}
request = Request(
    "https://api.brigg.app/v1/operations/workspace.GetJob",
    data=json.dumps(payload).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {os.environ['BRIGG_API_KEY']}",
        "Content-Type": "application/json",
        "Brigg-Act-As": os.environ["BRIGG_ACT_AS"],
    },
    method="POST",
)
try:
    with urlopen(request) as response:
        print(json.load(response))
except HTTPError as error:
    print(error.code, json.load(error))
    raise
```

#### Response example


```json
{
  "job_id": "job_document_proposal",
  "kind": "document_generation",
  "created_at": 1794301200000,
  "updated_at": 1794301260000,
  "retry_at": null,
  "result": null,
  "error": {
    "code": "job_failed",
    "message": "The work stopped. Review the task in Brigg before starting it again."
  },
  "status": "failed"
}
```

## JSON schemas


```json-schema-request
{
  "type": "object",
  "properties": {
    "job_id": {
      "type": "string",
      "minLength": 1,
      "description": "ID returned by a supported start operation, such as FillWordTemplate or GenerateBrief. Keep the same approved acting member used to start it."
    }
  },
  "required": [
    "job_id"
  ],
  "additionalProperties": false,
  "examples": [
    {
      "job_id": "job_document_proposal"
    }
  ]
}
```


```json-schema-response
{
  "title": "Job",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "job_id": {
      "type": "string",
      "description": "Opaque job identifier returned when the work starts."
    },
    "kind": {
      "type": "string",
      "enum": [
        "document_generation",
        "crm_import",
        "brief",
        "brief_action"
      ],
      "description": "The work this job performs."
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "running",
        "awaiting_input",
        "completed",
        "failed",
        "cancelled"
      ],
      "description": "Failed and cancelled are terminal. An automatically retried attempt remains queued. Awaiting_input needs a response in the task in Brigg; do not start duplicate work."
    },
    "created_at": {
      "type": "integer",
      "description": "Time the work was accepted, in Unix milliseconds."
    },
    "updated_at": {
      "type": "integer",
      "description": "Most recent progress change, in Unix milliseconds."
    },
    "retry_at": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Earliest suggested next check, in Unix milliseconds, or null when no specific time is supplied. Still poll with a delay and honor HTTP rate limits."
    },
    "result": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": false,
      "properties": {
        "file_id": {
          "type": "string",
          "description": "Generated file; use documents.GetFileDownload."
        },
        "resource_type": {
          "type": "string",
          "description": "Kind of the affected record."
        },
        "resource_id": {
          "type": "string",
          "description": "Affected record identifier; read the record for current values."
        },
        "imported": {
          "type": "integer",
          "description": "Records created or updated."
        }
      },
      "description": "Completion result selected by kind. Null while unfinished or when no public result is available. A resource_id identifies a record; it is not generated content."
    },
    "error": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "code": {
          "type": "string",
          "description": "Machine-readable code identifying this outcome or issue."
        },
        "message": {
          "type": "string",
          "description": "Human-readable explanation of the returned outcome."
        }
      },
      "required": [
        "code",
        "message"
      ],
      "additionalProperties": false,
      "description": "A terminal failure. Fix the cause and submit a new command with a new idempotency key; retrying the old command returns the same job."
    }
  },
  "required": [
    "job_id",
    "kind",
    "status",
    "created_at",
    "updated_at",
    "retry_at",
    "result",
    "error"
  ],
  "examples": [
    {
      "job_id": "job_document_proposal",
      "kind": "document_generation",
      "created_at": 1794301200000,
      "updated_at": 1794301260000,
      "retry_at": null,
      "result": null,
      "error": null,
      "status": "running"
    }
  ]
}
```

