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

# Change opportunity stage

> Move an opportunity to a Kanban stage, including sale and loss transitions.

```bash Regular stage theme={null}
curl --request PATCH \
  --url "https://app.cria.chat/api/v1/accounts/10/crm/inbox/25/kanban/opportunities/123/stage" \
  --header "api_access_token: YOUR_API_ACCESS_TOKEN" \
  --header "Accept: application/json" \
  --header "Content-Type: application/json" \
  --include \
  --data-raw '{
  "stage_id": 20
}'
```

```bash Sale stage theme={null}
curl --request PATCH \
  --url "https://app.cria.chat/api/v1/accounts/10/crm/inbox/25/kanban/opportunities/123/stage" \
  --header "api_access_token: YOUR_API_ACCESS_TOKEN" \
  --header "Accept: application/json" \
  --header "Content-Type: application/json" \
  --include \
  --data-raw '{
  "stage_id": 30,
  "sale": {
    "full_name": "Mary Johnson",
    "document": "52998224725",
    "mobile_phone": "+5511999999999",
    "invoice_number": "INV-2026-123",
    "value": 15000,
    "currency": "BRL",
    "third_party_document": false
  }
}'
```

```bash Loss stage theme={null}
curl --request PATCH \
  --url "https://app.cria.chat/api/v1/accounts/10/crm/inbox/25/kanban/opportunities/123/stage" \
  --header "api_access_token: YOUR_API_ACCESS_TOKEN" \
  --header "Accept: application/json" \
  --header "Content-Type: application/json" \
  --include \
  --data-raw '{
  "stage_id": 40,
  "lost": {
    "reason": "other",
    "notes": "The customer postponed the purchase until next year."
  }
}'
```

```json 200 OK theme={null}
{
  "data": {
    "opportunity_id": 123,
    "stage_id": 20,
    "status": "open",
    "transitioned": true
  }
}
```

```json 401 Unauthorized theme={null}
{
  "error": "Invalid Access Token"
}
```

```json 404 Not Found theme={null}
{
  "error": "Opportunity, inbox, or stage is invalid or inaccessible"
}
```

Move an existing opportunity to another stage in the same inbox. The destination stage determines whether additional sale or loss details are required.

## cURL examples

The request panel includes complete commands for regular, sale, and loss stage transitions. Replace `YOUR_API_ACCESS_TOKEN`, account ID `10`, inbox ID `25`, opportunity ID `123`, and stage IDs with values from your account. Stage IDs identify Kanban columns.

The cURL commands use Bash syntax. `--include` prints the HTTP status and response headers along with the JSON body.

## Authentication

Send a user or AgentBot API access token in the request header:

```http theme={null}
api_access_token: YOUR_API_ACCESS_TOKEN
Content-Type: application/json
```

The token must have access to the account and inbox. A session login alone does not authorize this endpoint.

Administrators can move accessible opportunities. Agents can move opportunities assigned to them, subject to the restrictions below. AgentBot tokens are treated as administrators for Kanban access.

## Path parameters

| Field | Required | Description |
| - | - | - |
| `account_id` | Yes | CriaChat account ID. |
| `inbox_id` | Yes | Inbox containing the opportunity. |
| `id` | Yes | Internal CriaChat opportunity ID, returned as `opportunity_id` by [Create opportunities](https://docs.cria.chat/api-reference/crm/opportunities/create.md). This is not the source system's `external_id`. |

## Common fields

| Field | Required | Description |
| - | - | - |
| `stage_id` | Yes | ID of an active, accessible Kanban column in the same inbox. |
| `sale` | For sale stages | Sale details for destination categories `sales` and `sales_BR`. |
| `lost` | For loss stages | Loss details for destination category `sales_lost`. |

## Move to a regular stage

```json theme={null}
{
  "stage_id": 20
}
```

The opportunity is placed at the end of the destination stage. Moving a won or lost opportunity to a regular stage reopens it and requires administrator privileges.

## Move to a sale stage

For stages categorized as `sales` or `sales_BR`, provide:

| Sale field | Required | Description |
| - | - | - |
| `full_name` | Yes | Customer's full name; also updates the linked contact name. |
| `document` | Yes | Customer document number. `sales_BR` stages require a valid CPF. |
| `mobile_phone` | Yes | Customer phone number, including country code; also updates the linked contact phone. |
| `invoice_number` | Yes | Invoice number. |
| `value` | Yes | Sale value. |
| `currency` | No | Sale currency; defaults to the opportunity's currency. |
| `third_party_document` | No | Whether a third party's document is used. |
| `third_party_document_number` | Conditional | Required when `third_party_document` is true. |
| `product` | No | Product name for boards without catalog restrictions. |
| `product_item_id` | No | Active product catalog item ID for boards with catalog restrictions. If omitted, the existing linked product item is retained. |

```json theme={null}
{
  "stage_id": 30,
  "sale": {
    "full_name": "Mary Johnson",
    "document": "52998224725",
    "mobile_phone": "+5511999999999",
    "invoice_number": "INV-2026-123",
    "value": 15000,
    "currency": "BRL",
    "third_party_document": false
  }
}
```

The transition marks the opportunity as `won`, records the sale details, and clears previous loss details.

## Move to a loss stage

For stages categorized as `sales_lost`, provide:

| Loss field | Required | Description |
| - | - | - |
| `reason` | Yes | One of the loss reasons listed below. |
| `notes` | Conditional | Required when `reason` is `other`; optional for other reasons. |

Accepted reasons: `price`, `no_response`, `credit_denied`, `competitor`, `unavailable`, `gave_up`, `invalid_contact`, `duplicate`, and `other`.

```json theme={null}
{
  "stage_id": 40,
  "lost": {
    "reason": "other",
    "notes": "The customer postponed the purchase until next year."
  }
}
```

The transition marks the opportunity as `lost` and records the reason, notes, and loss time.

## Validation and access rules

* The opportunity must be active (not archived) and belong to the specified inbox.
* The destination stage must be active, accessible, and belong to the same inbox. It can belong to another board within that inbox.
* An agent must be assigned to the opportunity to move it.
* Moving an opportunity that is already won or currently in a sale stage requires administrator privileges.
* Reopening a won or lost opportunity requires administrator privileges.
* Entering a stage with an enabled GIA campaign entry action requires administrator privileges and a linked contact.
* If the opportunity is already in the requested stage, the request leaves it unchanged and returns `transitioned: false`. Additional sale or loss details are not required for that no-op request.

## Response models

### 200 OK

Returns **200 OK**:

```json theme={null}
{
  "data": {
    "opportunity_id": 123,
    "stage_id": 20,
    "status": "open",
    "transitioned": true
  }
}
```

`status` is the resulting CriaChat opportunity status: `open`, `won`, or `lost`. `transitioned` indicates whether a stage change occurred.

| Field | Type | Description |
| - | - | - |
| `data.opportunity_id` | integer | Internal CriaChat opportunity ID. |
| `data.stage_id` | integer | Current stage ID after processing. |
| `data.status` | string | Resulting status: `open`, `won`, or `lost`. |
| `data.transitioned` | boolean | `true` when the stage changed; `false` when it was already the requested stage. |

### 401 Unauthorized

The API access token is missing or invalid. Account access failures and suspended accounts can also return `401`, with a different `error` message.

```json theme={null}
{
  "error": "Invalid Access Token"
}
```

### 404 Not Found

The opportunity, inbox, or destination stage is invalid or inaccessible. Archived opportunities are excluded from the lookup.

```json theme={null}
{
  "error": "Opportunity, inbox, or stage is invalid or inaccessible"
}
```

Both error examples use this model:

| Field | Type | Description |
| - | - | - |
| `error` | string | Reason the request failed. |

## Errors

| HTTP status | Meaning |
| - | - |
| `400` | Invalid CPF or unsupported loss reason. |
| `401` | Missing or invalid API access token, suspended account, or account access denied. |
| `403` | Opportunity access denied or administrator privileges required. |
| `404` | Opportunity, inbox, stage, or selected catalog item is invalid or inaccessible. Archived opportunities are excluded from the lookup. |
| `422` | Missing required parameters, inactive stage, destination in a different inbox, missing contact for a GIA stage, or model validation failure. |

Example resource error:

```json theme={null}
{
  "error": "Opportunity, inbox, or stage is invalid or inaccessible"
}
```


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