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

# Update the amount of a ticket

> Updates the amount of the active ticket, or the latest closed ticket if allow_closed_ticket is true. Provide ticket_id, ai_contact_id, or contact_number to identify the ticket. currency is required for price-source tickets and ignored for metadata-source tickets. For email contacts always provide ticket_id: their tickets are per-thread, so resolution by ai_contact_id or contact_number may return no ticket or one from a different thread.

## Overview

Updates the **amount** of a ticket. The amount represents the monetary value associated with the ticket (e.g. the deal value).

By default, this endpoint targets the contact's **active ticket**. Set `allow_closed_ticket` to `true` to fall back to the **latest closed ticket** when no active ticket exists.

<Note>
  Whether `currency` is required depends on how the ticket type is configured:

  * **Price-source tickets**: `currency` is **required**.
  * **Metadata-source tickets**: the amount is written to the configured custom field and `currency` is **ignored**.
</Note>

## Authentication

Include your API key in the request headers:

```bash theme={null}
x-api-key: your_api_key_here
```

## Request Body

| Field                 | Type            | Required     | Description                                                                                                    |
| --------------------- | --------------- | ------------ | -------------------------------------------------------------------------------------------------------------- |
| `ticket_id`           | `string` (UUID) | One of three | Directly target a ticket by its ID.                                                                            |
| `ai_contact_id`       | `string` (UUID) | One of three | Find the ticket through a contact ID.                                                                          |
| `contact_number`      | `string`        | One of three | Find the ticket through a contact phone number (e.g. `+56912345678`).                                          |
| `amount`              | `number`        | Yes          | The amount to set on the ticket.                                                                               |
| `currency`            | `string`        | Conditional  | ISO currency code (e.g. `CLP`, `USD`). Required for price-source tickets, ignored for metadata-source tickets. |
| `allow_closed_ticket` | `boolean`       | No           | When `true`, falls back to the latest closed ticket if no active ticket exists. Defaults to `false`.           |

> You must provide **exactly one** identifier: `ticket_id`, `ai_contact_id`, or `contact_number`.

## Example Requests

### By contact number

```bash theme={null}
curl --request POST \
  'https://api.vambe.me/api/public/ticket/amount' \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: your_api_key_here' \
  --data-raw '{
    "contact_number": "+56912345678",
    "amount": 150000,
    "currency": "CLP"
  }'
```

### By AI contact ID (with closed ticket fallback)

```bash theme={null}
curl --request POST \
  'https://api.vambe.me/api/public/ticket/amount' \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: your_api_key_here' \
  --data-raw '{
    "ai_contact_id": "df980fc8-b6db-4820-bf22-2969482d106d",
    "allow_closed_ticket": true,
    "amount": 99990,
    "currency": "CLP"
  }'
```

### By ticket ID

```bash theme={null}
curl --request POST \
  'https://api.vambe.me/api/public/ticket/amount' \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: your_api_key_here' \
  --data-raw '{
    "ticket_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "amount": 250000,
    "currency": "USD"
  }'
```

## Responses

### 200 - Success

```json theme={null}
{
  "status": "ok"
}
```

### 400 - Bad Request

Returned when no identifier is provided, the request body is invalid, or `currency` is missing for a price-source ticket.

```json theme={null}
{
  "statusCode": 400,
  "message": "You must provide ticket_id, ai_contact_id, or contact_number"
}
```

### 404 - Not Found

Returned when the contact or ticket cannot be found.

```json theme={null}
{
  "statusCode": 404,
  "message": "Active ticket not found for contact"
}
```


## OpenAPI

````yaml post /api/public/ticket/amount
openapi: 3.0.0
info:
  title: Vambe AI API
  description: Vambe AI documentation
  version: '1.0'
  contact: {}
servers:
  - url: https://api.vambe.me
    description: Production Server
security: []
tags:
  - name: Vambe AI
    description: ''
paths:
  /api/public/ticket/amount:
    post:
      tags:
        - Ticket
      summary: Update the amount of a ticket
      description: >-
        Updates the amount of the active ticket, or the latest closed ticket if
        allow_closed_ticket is true. Provide ticket_id, ai_contact_id, or
        contact_number to identify the ticket. currency is required for
        price-source tickets and ignored for metadata-source tickets. For email
        contacts always provide ticket_id: their tickets are per-thread, so
        resolution by ai_contact_id or contact_number may return no ticket or
        one from a different thread.
      operationId: UpdateTicketPublicController_updateTicketAmount
      parameters:
        - name: x-api-key
          in: header
          description: API key needed to authorize the request
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                ticket_id:
                  format: uuid
                  type: string
                ai_contact_id:
                  format: uuid
                  type: string
                contact_number:
                  type: string
                amount:
                  type: number
                currency:
                  type: string
                  example: CLP
                allow_closed_ticket:
                  type: boolean
              required:
                - amount
              example:
                contact_number: '+56912345678'
                amount: 150000
                currency: CLP
      responses:
        '200':
          description: Ticket amount updated successfully
        '400':
          description: >-
            Invalid request - provide ticket_id, ai_contact_id, or
            contact_number
        '404':
          description: Ticket not found

````