# Move an office's unsent claims to another office

Page: https://app.myclaimhouse.com/docs/api/moveOfficeClaims

`POST /api/v1/offices/{id}/move_claims`

Moves the unsent claims and predeterminations of the office to another office of the same organization and mode (to_office_id): its drafts, the ones that need attention, the validated and the queued ones, and the rejected ones the payer never gave a number. A claim that was sent, or that the payer has (a claim with a payer claim number, a correction, a void transaction), stays with the office that sent it, with its files, payments and ERAs. Each moved claim gets a timeline entry (moved) and is validated for its new office, as after an edit: one that was queued is queued again when it still has no error, one that no longer validates needs attention, a draft and a rejected claim stay as they are. Attachments stay on their claims and keep the office they were made for. A request moves at most 100 claims, the queued ones first, all of them or none: while more is true, send it again with a new Idempotency-Key. A key with submit and no read moves the claims it made. The office in the path that is another organization's or the other mode's is not found; such a to_office_id, or the office itself, is a 422 on to_office_id. Needs an Idempotency-Key header and a key with the submit permission.

Needs a key with `submit` permission.

## Request

### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | string | Yes | Makes the request safe to repeat: a request with the same key and body returns the first answer (the reply has an idempotent-replayed header), and the same key with a different request is refused. 1 to 255 printable characters; a UUID is a good choice. At least 1 character. At most 255 characters. Matches `^[\x21-\x7e]{1,255}$`. |

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | An office ID (off_...). |

### Body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `to_office_id` | string | Yes | The office the claims move to (off_...): another office of the same organization and mode. |

## Response

How many claims moved, by the state each was in. Status `200`.

| Name | Type | Description |
| --- | --- | --- |
| `object` | string | Always `office_claims_move`. |
| `from_office_id` | string | An ID that starts with off_. |
| `to_office_id` | string | An ID that starts with off_. |
| `moved` | object | How many claims moved, by the state each was in when it moved. Each was then validated for its new office; the queued ones were queued again when they still had no error. |
| `moved.draft` | integer | At least -9007199254740991. |
| `moved.needs_attention` | integer | At least -9007199254740991. |
| `moved.validated` | integer | At least -9007199254740991. |
| `moved.rejected` | integer | At least -9007199254740991. |
| `moved.queued` | integer | At least -9007199254740991. |
| `total` | integer | How many claims this request moved. At least -9007199254740991. |
| `more` | boolean | True when the office still has unsent claims: a request moves at most 100. Send it again, with a new Idempotency-Key, until this is false. |

## Errors

| HTTP status | Code | What it means |
| --- | --- | --- |
| 401 | `UNAUTHORIZED` | A valid API key is required. Send it as "Authorization: Bearer <key>". |
| 403 | `PERMISSION_DENIED` | This API key is not allowed to do that. |
| 404 | `NOT_FOUND` | Not found. |
| 422 | `INVALID_REQUEST` | The request is not valid. |
| 400 | `IDEMPOTENCY_KEY_REQUIRED` | This request needs an Idempotency-Key header: a value you make up (a UUID is good), new for each new request. |
| 400 | `IDEMPOTENCY_KEY_INVALID` | The Idempotency-Key header must be 1 to 255 printable characters. |
| 422 | `IDEMPOTENCY_KEY_REUSED` | That Idempotency-Key was already used with a different request. |
| 409 | `IDEMPOTENCY_KEY_IN_USE` | A request with that Idempotency-Key is still running. Send it again with the same key after Retry-After seconds. |
| 429 | `TOO_MANY_REQUESTS` | Too many requests of this kind lately. Wait, then try again. |
| 413 | `PAYLOAD_TOO_LARGE` | The request body is larger than 1 MB. |
| 504 | `TIMEOUT` | The request took too long. Send it again with the same Idempotency-Key and body after Retry-After seconds: a 409 means it is still finishing (wait and send again), and any other answer is final. If this 504 comes back, find what the request made by listing with ?idempotency_key=<the key>. |
| 503 | `CLAIMS_UNAVAILABLE` | Claims are not available in live mode yet. Use a test key. |
| 500 | `INTERNAL` | Something went wrong on our side. Quote the request ID if you contact us. |

## Example

### Example request

```bash
curl -X POST "https://app.myclaimhouse.com/api/v1/offices/off_01JM000000E008000000000003/move_claims" \
  -H "Authorization: Bearer $CLAIMHOUSE_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "to_office_id": "off_01JM000000E008000000000091"
}'
```

### Example response: 200

```json
{
  "object": "office_claims_move",
  "from_office_id": "off_01JM000000E008000000000003",
  "to_office_id": "off_01JM000000E008000000000091",
  "moved": {
    "draft": 2,
    "needs_attention": 1,
    "validated": 0,
    "rejected": 1,
    "queued": 3
  },
  "total": 7,
  "more": false
}
```
