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

# Raise and complete work

> Report a problem, turn it into a work order, assign it, move it through its statuses and close it from another system.

This guide follows one problem from report to closed work order. The examples assume a token in
`$TOKEN` ([Authentication](/api-reference/authentication)) and an asset to raise work against
([Add an asset](/api-reference/guides/add-an-asset)).

There are two ways in:

* **A work request** is a report that a person triages. Use it when your system notices something and
  somebody should decide what happens, such as a building management system raising an alarm.
* **A work order** is a job. Raise one directly when the decision is already made, such as a
  production system booking a planned repair.

## Report a problem

```bash theme={null}
curl -X POST https://app.assetinfinity.ai/api/rpc/create_work_request \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"p_summary": "Pump 2 is leaking at the seal", "p_asset_id": "d54f41c3-a627-4429-826a-c82cbbecae2b", "p_severity": "HIGH", "p_source_code": "API"}'
```

```json theme={null}
{ "id": "4ceb523d-fbe6-48ef-b06d-eaea42a103ad", "request_number": "WR-2026-00003",
  "summary": "Pump 2 is leaking at the seal", "status": "SUBMITTED", "source": "API" }
```

`p_asset_id` is optional, because somebody reporting a smell in a corridor should not have to name an
asset first. Send `p_site_id` or `p_location_id` instead when there is no asset.

The request waits in the queue on the **Work requests** screen. A person can turn it into a work order
there, or your system can do it:

```bash theme={null}
curl -X POST https://app.assetinfinity.ai/api/rpc/convert_work_request \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"p_work_request_id": "4ceb523d-fbe6-48ef-b06d-eaea42a103ad"}'
```

The answer is the new work order. `reject_work_request` with a `p_reason` turns a request down
instead, and the person who raised it reads the reason.

## Or raise a work order directly

```bash theme={null}
curl -X POST https://app.assetinfinity.ai/api/rpc/create_work_order \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"p_title": "Replace seal on pump 2", "p_asset_id": "d54f41c3-a627-4429-826a-c82cbbecae2b", "p_priority_code": "HIGH", "p_due_at": "2026-10-10T17:00:00Z"}'
```

```json theme={null}
{ "id": "1d822495-12a5-436c-950f-5abdc2777d8d", "work_order_number": "WO-2026-00028",
  "status": "OPEN", "priority": "HIGH", "site_id": "a649ba48-4cf1-4f63-9273-a205f12d9ee9",
  "due_at": "2026-10-10T17:00:00+00:00" }
```

Only `p_title` is required. The site comes from the asset. `p_work_order_type_code` defaults to
`CORRECTIVE`. List your organisation's types with `/work_order_types?select=code,name`.

## Assign it

Find the technician's `worker_id`:

```bash theme={null}
curl "https://app.assetinfinity.ai/api/technicians?select=worker_id,worker_number,name&worker_number=eq.W-1001" \
  -H "Authorization: Bearer $TOKEN"
```

```bash theme={null}
curl -X POST https://app.assetinfinity.ai/api/rpc/assign_work_order \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"p_work_order_id": "1d822495-12a5-436c-950f-5abdc2777d8d", "p_worker_id": "3e32ffa9-3517-4693-b5b1-54440c201018"}'
```

Assigning moves the work order to **Assigned**. Send `p_team_id` instead of `p_worker_id` to give it
to a crew.

## Move it through its statuses

Statuses and the moves between them are set by your organisation, so ask before you move.
`available_transitions` lists the moves this work order allows now, and what each one needs:

```bash theme={null}
curl -X POST https://app.assetinfinity.ai/api/rpc/available_transitions \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"p_work_order_id": "1d822495-12a5-436c-950f-5abdc2777d8d"}'
```

```json theme={null}
[
  { "from_status": "IN_PROGRESS", "to_status": "COMPLETED", "permitted": true,
    "needs_failure_code": true, "needs_resolution_code": true,
    "needs_custom_fields": ["production_batch"], "blockers": [] }
]
```

Move it with `transition_work_order` and the status code. With the default statuses a work order goes
from **Assigned** to **Accepted** to **In Progress**:

```bash theme={null}
curl -X POST https://app.assetinfinity.ai/api/rpc/transition_work_order \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"p_work_order_id": "1d822495-12a5-436c-950f-5abdc2777d8d", "p_to_status": "ACCEPTED"}'
```

`/work_order_statuses?select=code,display_name,category&order=sort_order` lists your organisation's
statuses.

## Complete it

Completing records what was found and what was done. Send what `available_transitions` said the move
needs:

| It said | Send |
| - | - |
| `needs_failure_code` | `p_failure_code`, a code from `/failure_modes?select=code,name` |
| `needs_resolution_code` | `p_resolution_code`, a code from `/work_order_resolution_codes?select=code,name` |
| `needs_custom_fields` | Answer each field first with `set_custom_field_value` |

```bash theme={null}
curl -X POST https://app.assetinfinity.ai/api/rpc/set_custom_field_value \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"p_entity": "core.work_orders", "p_entity_id": "1d822495-12a5-436c-950f-5abdc2777d8d", "p_field_key": "production_batch", "p_value": "B-2210"}'
```

```bash theme={null}
curl -X POST https://app.assetinfinity.ai/api/rpc/complete_work_order \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
        "p_work_order_id": "1d822495-12a5-436c-950f-5abdc2777d8d",
        "p_resolution_notes": "Seal replaced; no leak after 30 minutes running.",
        "p_failure_code": "LEAK",
        "p_resolution_code": "REPLACED",
        "p_is_first_time_fix": true
      }'
```

The failure code and whether it was fixed first time feed the reliability figures later, which is why
they are asked for here.

If something is missing, the work order stays where it is and the answer says what to add. See
[Errors](/api-reference/errors) for real examples.

## Close it

```bash theme={null}
curl -X POST https://app.assetinfinity.ai/api/rpc/close_work_order \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"p_work_order_id": "1d822495-12a5-436c-950f-5abdc2777d8d"}'
```

```bash theme={null}
curl "https://app.assetinfinity.ai/api/work_orders?select=work_order_number,status&work_order_number=eq.WO-2026-00028" \
  -H "Authorization: Bearer $TOKEN"
```

```json theme={null}
[{ "work_order_number": "WO-2026-00028", "status": "CLOSED" }]
```

## Hear about changes instead of asking

To be told when a work order changes, rather than reading `/work_orders` on a timer, register a
webhook endpoint with `save_webhook_endpoint`. The **Webhooks** section under **Integration API** has
the calls, and [Webhooks](/config/webhooks) describes the events.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.