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

# Webhook

> The Webhook is used to receive events related to Positus products that belong to the workspace.

# Webhook

To configure the workspace webhook, access: [https://studio.posit.us/workspace/configuracoes](https://studio.posit.us/workspace/configuracoes)

Every event delivered to your webhook follows the same envelope: an `event` field with the event name, a `workspace` object identifying the source workspace, and an object with the resource related to the event (`number`, `template`, etc.). Delivery is done via HTTP `POST`.

**`workspace` object**

| Field           | Description                                               |
| --------------- | --------------------------------------------------------- |
| id              | Workspace identifier (UUID)                               |
| provider        | Workspace provider: `{ "id", "name" }`                    |
| type\_workspace | Workspace type: `{ "id", "name" }` (Receptive / Prospect) |
| name            | Workspace name                                            |
| business\_id    | Business Manager ID on Meta                               |
| waba\_id        | WABA ID on Meta                                           |

## Phone number quality classification

Receive in your webhook the quality of each WhatsApp number in order to maintain better integration with your CRM, thus improving the management quality of your numbers.

* Undefined: not yet classified
* Green: high quality
* Yellow: medium quality
* Red: low quality

### Number events

| Event Type                     | Description                                                                                                                                       |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| phone\_number\_status\_update  | Sent in real time whenever the status, quality classification (`quality_rating`) or messaging limit (`messaging_limit`) of the number is updated. |
| phone\_number\_quality\_update | Sent during the periodic synchronization of numbers. Uses a flat payload format (see the example below).                                          |
| phone\_number\_sync            | Sent during the periodic synchronization, reflecting the current state of the number.                                                             |

### Number status

| **Number status** | Description                                       |
| ----------------- | ------------------------------------------------- |
| 1                 | Number awaiting approval                          |
| 2                 | Number awaiting server creation                   |
| 3                 | Number awaiting server authentication             |
| 4                 | Number awaiting server installation               |
| 5                 | Number awaiting server configuration              |
| 6                 | Number awaiting activation                        |
| 7                 | Active number                                     |
| 8                 | Inactive number                                   |
| 9                 | Deleted number                                    |
| 10                | Awaiting migration to Cloud Api                   |
| 11                | Number awaiting server reboot                     |
| 12                | Number awaiting activation completion by the user |
| 13                | Banned number                                     |
| 14                | Number awaiting restoration                       |
| 15                | Transferred number                                |

### Quality status (`quality_status`)

| ID | Code      |
| -- | --------- |
| 0  | UNKNOWN   |
| 1  | CONNECTED |
| 2  | FLAGGED   |
| 3  | MIGRATED  |

### Quality classification (`quality_rating`)

| ID | Quality classification description |
| -- | ---------------------------------- |
| 0  | UNKNOWN                            |
| 1  | GREEN                              |
| 2  | YELLOW                             |
| 3  | RED                                |

### Messaging limit (`messaging_limit`)

| ID | amount    | formatted\_amount |
| -- | --------- | ----------------- |
| 0  | UNKNOWN   | Unknown           |
| 1  | 1000      | 1.000             |
| 2  | 10000     | 10.000            |
| 3  | 100000    | 100.000           |
| 4  | UNLIMITED | Unlimited         |
| 5  | 50        | 50                |
| 6  | 250       | 250               |
| 7  | 2000      | 2.000             |

### Example payload — `phone_number_status_update`

```json theme={null}
POST / {
    "event": "phone_number_status_update",
    "workspace": {
        "id": "0baf1974-2ccc-41dd-8659-594da132edd2",
        "provider": {
            "id": 1,
            "name": "Positus V2"
        },
        "type_workspace": {
            "id": 1,
            "name": "Receptivo"
        },
        "name": "Estúdio Rilo",
        "business_id": "857420775150360",
        "waba_id": "1781395745366162"
    },
    "number": {
        "id": "96b3092d-bff9-4f53-bf46-74e5fb126043",
        "business_manager": {
            "business_portfolio_id": "857420775150360",
            "current_limit": 100000,
            "max_daily_conversations_per_business": 100000,
            "max_daily_conversation_per_phone": 1000,
            "max_phone_numbers_per_business": 20,
            "max_phone_numbers_per_waba": 20,
            "quality_rating": "HIGH",
            "throughput_level": "1000_mps"
        },
        "status": {
            "id": 7,
            "description": "Número ativo"
        },
        "quality_status": {
            "id": 1,
            "code": "CONNECTED"
        },
        "quality_rating": {
            "id": 1,
            "code": "GREEN"
        },
        "messaging_limit": {
            "id": 3,
            "amount": 100000,
            "formatted_amount": "100.000"
        },
        "official_business_account": true,
        "name": "Estudio Rilo",
        "country_code": "55",
        "number": "4333385841",
        "display_phone_number": "554333385841"
    }
}
```

### Example payload — `phone_number_quality_update`

The synchronization event uses a flat payload format, with the Business Manager limits at the number level and `quality_rating` as text.

```json theme={null}
POST / {
    "event": "phone_number_quality_update",
    "workspace": {
        "id": "0baf1974-2ccc-41dd-8659-594da132edd2",
        "provider": {
            "id": 1,
            "name": "Positus V2"
        },
        "type_workspace": {
            "id": 1,
            "name": "Receptivo"
        },
        "name": "Estúdio Rilo",
        "business_id": "857420775150360",
        "waba_id": "1781395745366162"
    },
    "number": {
        "id": "96b3092d-bff9-4f53-bf46-74e5fb126043",
        "business_portfolio_id": "857420775150360",
        "current_limit": 100000,
        "max_daily_conversations_per_business": 100000,
        "max_daily_conversation_per_phone": 1000,
        "max_phone_numbers_per_business": 20,
        "max_phone_numbers_per_waba": 20,
        "quality_rating": "HIGH",
        "throughput_level": "1000_mps",
        "status": {
            "id": 7,
            "description": "Número ativo"
        },
        "quality_status": {
            "id": 1,
            "code": "CONNECTED"
        },
        "messaging_limit": {
            "id": 3,
            "amount": 100000,
            "formatted_amount": "100.000"
        },
        "official_business_account": true,
        "name": "Estudio Rilo",
        "country_code": "55",
        "number": "4333385841",
        "display_phone_number": "554333385841"
    }
}
```

## Template message

Receive template approval notifications through your webhook. The `message_template_status_update` event is sent whenever the approval status of a template is changed.

### Template status

| ID | Code (code)       | Description      |
| -- | ----------------- | ---------------- |
| 0  | UNDEFINED         | Undefined        |
| 1  | PENDING           | Pending          |
| 2  | APPROVED          | Approved         |
| 3  | REJECTED          | Rejected         |
| 4  | IN\_APPEAL        | In appeal        |
| 5  | PENDING\_DELETION | Pending deletion |
| 6  | DELETED           | Deleted          |
| 7  | DISABLED          | Disabled         |
| 8  | FLAGGED           | Flagged          |
| 9  | REINSTATED        | Reinstated       |
| 10 | PAUSED            | Paused           |
| 11 | PAUSED            | Paused           |

### Example payload — `message_template_status_update`

```json theme={null}
POST / {
    "event": "message_template_status_update",
    "workspace": {
        "id": "93834938-3242-131321-bbb3-123131321",
        "provider": {
            "id": 2,
            "name": "Robbu"
        },
        "type_workspace": {
            "id": 1,
            "name": "Receptivo"
        },
        "name": "Robbu",
        "business_id": "8274562463464",
        "waba_id": "7362e34823764823"
    },
    "template": {
        "id": "us737373736s616-dsf2342-fd23-b324ea8-23423fd13",
        "status": {
            "id": 2,
            "code": "APPROVED",
            "description": "Aprovado"
        },
        "quality_score": {
            "id": 1,
            "code": "GREEN"
        },
        "category": {
            "id": 11,
            "code": "AUTO_REPLY",
            "description": "Resposta automática"
        },
        "language": {
            "id": 46,
            "code": "pt_BR",
            "name": "Portuguese (BR)"
        },
        "name": "abertura_janela_01",
        "components": [{
            "type": "BODY",
            "text": "{{1}}, desculpe a demora para responder sua mensagem. Você quer continuar nossa conversa?"
        }]
    }
}
```
