# API reference

Every route, its fields and an example.

# API reference

Base URL: https://hira.localtechstudio.com/api/v1

## Messages

### GET /messages

Conversation history (connectionId + to E.164, cursor after)

```bash
curl https://hira.localtechstudio.com/api/v1/messages \
  -H "Authorization: Bearer pk_live_…"
```

### POST /messages

Send a message (exactly one content field; includes video, product, productList)

- `connectionId`: string
- `to`: string
- `text`: string
- `image`: object
- `document`: object
- `audio`: object
- `template`: object
- `buttons`: object
- `list`: object
- `cta`: object
- `smart`: object
- `otp`: object
- `flow`: object
- `callPermissionRequest`: object
- `reaction`: object
- `raw`: object

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/messages \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"connectionId":"con_01H…","to":"+237600000000","text":"Bonjour"}'
```

### GET /messages/{id}

Message status

```bash
curl https://hira.localtechstudio.com/api/v1/messages/… \
  -H "Authorization: Bearer pk_live_…"
```

## Connected numbers

### POST /connect-links

Create a one-time link to connect a number (partner key required). Optional `externalRef` and `expiresInMinutes` (60 by default, 10,080 max). The `url` is returned once and can be used for a single connection

- `externalRef`: string
- `expiresInMinutes`: integer

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/connect-links \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"externalRef":"client-4821","expiresInMinutes":60}'
```

### GET /connections

List connected numbers

```bash
curl https://hira.localtechstudio.com/api/v1/connections \
  -H "Authorization: Bearer pk_live_…"
```

### GET /connections/{id}

Connection details (never includes the token)

```bash
curl https://hira.localtechstudio.com/api/v1/connections/… \
  -H "Authorization: Bearer pk_live_…"
```

### DELETE /connections/{id}

Disconnect a number from the platform (token cleared). Reconnect later via Embedded Signup without using an extra slot

```bash
curl -X DELETE https://hira.localtechstudio.com/api/v1/connections/… \
  -H "Authorization: Bearer pk_live_…"
```

### GET /connections/{id}/catalogs

Meta product catalogs linked to the WABA

```bash
curl https://hira.localtechstudio.com/api/v1/connections/…/catalogs \
  -H "Authorization: Bearer pk_live_…"
```

### GET /connections/{id}/catalogs/{catalogId}/products

Products of a Meta catalog

```bash
curl https://hira.localtechstudio.com/api/v1/connections/…/catalogs/…/products \
  -H "Authorization: Bearer pk_live_…"
```

### GET /connections/{id}/calling

Calling settings of the number

```bash
curl https://hira.localtechstudio.com/api/v1/connections/…/calling \
  -H "Authorization: Bearer pk_live_…"
```

### PATCH /connections/{id}/calling

Update calling settings: activation, call icon, opening hours, callback permission

- `status`: ENABLED | DISABLED
- `callIconVisibility`: DEFAULT | DISABLE_ALL
- `callbackPermissionStatus`: ENABLED | DISABLED
- `callHours`: object

```bash
curl -X PATCH https://hira.localtechstudio.com/api/v1/connections/…/calling \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"status":"ENABLED","callIconVisibility":"DEFAULT","callbackPermissionStatus":"ENABLED","callHours":{"status":"ENABLED","timezoneId":"string","weeklyOperatingHours":["string"],"holidaySchedule":["string"]}}'
```

### GET /connections/{id}/call-permissions

A customer's call permission (query parameter `to`) and remaining limits

```bash
curl https://hira.localtechstudio.com/api/v1/connections/…/call-permissions \
  -H "Authorization: Bearer pk_live_…"
```

## Contacts and tags

### GET /contacts

List contacts (filters companyId, tag, q, optedOut)

```bash
curl https://hira.localtechstudio.com/api/v1/contacts \
  -H "Authorization: Bearer pk_live_…"
```

### POST /contacts

Create or update a contact by number (normalised, one contact per number)

- `companyId`: string
- `phone`: string
- `country`: string
- `name`: string
- `fields`: object
- `tags`: array
- `consent`: boolean

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/contacts \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"companyId":"cmp_01H…","phone":"+237 6 99 12 34 56","name":"Awa","tags":["VIP"],"consent":true}'
```

### POST /contacts/import

Import contacts (JSON rows or csv text, 50,000 rows max). Recognised columns: number, name, tags, consent, country (CM, SN, FR or 237, row by row); other columns become fields usable in variables

- `companyId`: string
- `rows`: array
- `csv`: string
- `tags`: array
- `consent`: boolean
- `defaultCountryCode`: string

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/contacts/import \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"companyId":"string","rows":[{}],"csv":"string","tags":["string"],"consent":true,"defaultCountryCode":"string"}'
```

### GET /contacts/{id}

Contact details

```bash
curl https://hira.localtechstudio.com/api/v1/contacts/… \
  -H "Authorization: Bearer pk_live_…"
```

### PATCH /contacts/{id}

Update a contact (name, fields, tags, addTags, removeTags, consent)

```bash
curl -X PATCH https://hira.localtechstudio.com/api/v1/contacts/… \
  -H "Authorization: Bearer pk_live_…"
```

### DELETE /contacts/{id}

Delete a contact

```bash
curl -X DELETE https://hira.localtechstudio.com/api/v1/contacts/… \
  -H "Authorization: Bearer pk_live_…"
```

### POST /contacts/{id}/opt-out

Opt a contact out: set aside from every campaign, including running ones

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/contacts/…/opt-out \
  -H "Authorization: Bearer pk_live_…"
```

### POST /contacts/{id}/opt-in

Opt a contact back in after they gave consent again

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/contacts/…/opt-in \
  -H "Authorization: Bearer pk_live_…"
```

### GET /tags

List tags and their contact count

```bash
curl https://hira.localtechstudio.com/api/v1/tags \
  -H "Authorization: Bearer pk_live_…"
```

## Campaigns

### GET /campaigns

List campaigns (filters status, connectionId)

```bash
curl https://hira.localtechstudio.com/api/v1/campaigns \
  -H "Authorization: Bearer pk_live_…"
```

### POST /campaigns

Prepare a campaign (draft). Content: `template` (Meta) or `text` (free-form 24h: {{name}}, {{phone}}, {{city}} or {{field:city}}, {{date}}, {{company}}, {{numero}}…). Recipients: `recipients` and/or `audience`. STOP skipped; MARKETING needs consent. Outside window → `window_closed`

- `connectionId`: string
- `template`: object
- `text`: string
- `name`: string
- `recipients`: array
- `audience`: object
- `variableMap`: array
- `requireConsent`: boolean
- `defaultCountryCode`: string

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/campaigns \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"connectionId":"con_01H…","template":{"name":"promo","language":"fr"},"audience":{"tags":["VIP"]},"variableMap":[{"source":"name","default":"cliente"}]}'
```

### GET /campaigns/{id}

Campaign details and its recipients

```bash
curl https://hira.localtechstudio.com/api/v1/campaigns/… \
  -H "Authorization: Bearer pk_live_…"
```

### GET /campaigns/{id}/preview

Check before sending: recipients kept, skipped by reason, estimated duration, number tier and quality, quota

```bash
curl https://hira.localtechstudio.com/api/v1/campaigns/…/preview \
  -H "Authorization: Bearer pk_live_…"
```

### POST /campaigns/{id}/launch

Launch a campaign, or schedule it with `scheduledAt` (up to 60 days). The list is checked against the quota and the number tier before the first send

- `scheduledAt`: string

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/campaigns/…/launch \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"scheduledAt":"2026-12-01T08:00:00Z"}'
```

### POST /campaigns/{id}/pause

Pause a running campaign (immediate effect)

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/campaigns/…/pause \
  -H "Authorization: Bearer pk_live_…"
```

### POST /campaigns/{id}/resume

Resume a paused campaign

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/campaigns/…/resume \
  -H "Authorization: Bearer pk_live_…"
```

### POST /campaigns/{id}/cancel

Cancel a campaign: remaining sends are set aside

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/campaigns/…/cancel \
  -H "Authorization: Bearer pk_live_…"
```

### POST /campaigns/{id}/test

Send a test to a number (counts toward the quota)

- `to`: string

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/campaigns/…/test \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"to":"string"}'
```

### GET /campaigns/{id}/report

Report: delivery, read, reply, click and STOP rates, hour-by-hour curve, failure causes

```bash
curl https://hira.localtechstudio.com/api/v1/campaigns/…/report \
  -H "Authorization: Bearer pk_live_…"
```

### GET /campaigns/{id}/export

CSV export of every recipient and its status

```bash
curl https://hira.localtechstudio.com/api/v1/campaigns/…/export \
  -H "Authorization: Bearer pk_live_…"
```

### POST /campaigns/{id}/retarget

Follow up: creates a draft with those who did not read (not_read), did not reply (not_replied) or failed (failed)

- `mode`: not_read | not_replied | failed
- `name`: string

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/campaigns/…/retarget \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"mode":"not_read"}'
```

## Automations

### GET /automations

List automations (filter connectionId)

```bash
curl https://hira.localtechstudio.com/api/v1/automations \
  -H "Authorization: Bearer pk_live_…"
```

### POST /automations

Create an automation for a number: `trigger` (`message_received`, `contact_created`, `campaign_completed`, `conversation_unanswered`), up to 5 `conditions` and up to 5 `actions` (`send_smart`, `send_template`, `add_tag`, `notify_team`, `webhook` over https, `send_flow`, `assign_conversation`)

- `connectionId`: string
- `name`: string
- `enabled`: boolean
- `trigger`: message_received | contact_created | campaign_completed | conversation_unanswered
- `conditions`: array
- `actions`: array

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/automations \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"connectionId":"con_01H…","name":"Accueil","trigger":"message_received","actions":[{"type":"add_tag","tag":"a_ecrit"}]}'
```

### GET /automations/{id}

Automation details

```bash
curl https://hira.localtechstudio.com/api/v1/automations/… \
  -H "Authorization: Bearer pk_live_…"
```

### PATCH /automations/{id}

Update an automation (`enabled: false` pauses it)

```bash
curl -X PATCH https://hira.localtechstudio.com/api/v1/automations/… \
  -H "Authorization: Bearer pk_live_…"
```

### DELETE /automations/{id}

Delete an automation

```bash
curl -X DELETE https://hira.localtechstudio.com/api/v1/automations/… \
  -H "Authorization: Bearer pk_live_…"
```

### GET /automations/{id}/runs

Run history: status, context, result per action and error

```bash
curl https://hira.localtechstudio.com/api/v1/automations/…/runs \
  -H "Authorization: Bearer pk_live_…"
```

## Templates and media

### POST /templates/sync

Sync templates from Meta

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/templates/sync \
  -H "Authorization: Bearer pk_live_…"
```

### GET /templates

List templates

```bash
curl https://hira.localtechstudio.com/api/v1/templates \
  -H "Authorization: Bearer pk_live_…"
```

### POST /templates

Create a template

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/templates \
  -H "Authorization: Bearer pk_live_…"
```

### GET /templates/{id}

Template details

```bash
curl https://hira.localtechstudio.com/api/v1/templates/… \
  -H "Authorization: Bearer pk_live_…"
```

### DELETE /templates/{id}

Delete a template

```bash
curl -X DELETE https://hira.localtechstudio.com/api/v1/templates/… \
  -H "Authorization: Bearer pk_live_…"
```

### POST /media

Upload a media file (multipart, field file); deduplicated, quota counts new bytes only

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/media \
  -H "Authorization: Bearer pk_live_…"
```

### POST /media/header-handle

Get a header_handle for a template

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/media/header-handle \
  -H "Authorization: Bearer pk_live_…"
```

## Webhooks

### GET /webhook-endpoints

List outgoing webhooks

```bash
curl https://hira.localtechstudio.com/api/v1/webhook-endpoints \
  -H "Authorization: Bearer pk_live_…"
```

### POST /webhook-endpoints

Create a webhook (whsec_… secret shown once; deliveries signed with X-Wa-Signature)

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/webhook-endpoints \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/webhooks/whatsapp","scope":"account"}'
```

### PATCH /webhook-endpoints/{id}

Update a webhook URL or events filter

```bash
curl -X PATCH https://hira.localtechstudio.com/api/v1/webhook-endpoints/… \
  -H "Authorization: Bearer pk_live_…"
```

### DELETE /webhook-endpoints/{id}

Delete a webhook

```bash
curl -X DELETE https://hira.localtechstudio.com/api/v1/webhook-endpoints/… \
  -H "Authorization: Bearer pk_live_…"
```

### GET /flow-endpoints

List Flow callbacks

```bash
curl https://hira.localtechstudio.com/api/v1/flow-endpoints \
  -H "Authorization: Bearer pk_live_…"
```

### POST /flow-endpoints

Create a Flow callback

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/flow-endpoints \
  -H "Authorization: Bearer pk_live_…"
```

### PATCH /flow-endpoints/{id}

Update a Flow callback URL

```bash
curl -X PATCH https://hira.localtechstudio.com/api/v1/flow-endpoints/… \
  -H "Authorization: Bearer pk_live_…"
```

### DELETE /flow-endpoints/{id}

Delete a Flow callback

```bash
curl -X DELETE https://hira.localtechstudio.com/api/v1/flow-endpoints/… \
  -H "Authorization: Bearer pk_live_…"
```

## Calls

### GET /calls

List calls (filters connectionId, direction, status)

```bash
curl https://hira.localtechstudio.com/api/v1/calls \
  -H "Authorization: Bearer pk_live_…"
```

### POST /calls

Start an outbound call with an SDP offer (the customer's permission is required)

- `connectionId`: string
- `to`: string
- `sdpOffer`: string
- `bizOpaqueCallbackData`: string

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/calls \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"connectionId":"con_01H…","to":"+237600000000","sdpOffer":"v=0…"}'
```

### GET /calls/{id}

Call details (a cal_… identifier or Meta's wacid… identifier)

```bash
curl https://hira.localtechstudio.com/api/v1/calls/… \
  -H "Authorization: Bearer pk_live_…"
```

### POST /calls/{id}/pre-accept

Pre-accept an inbound call with the SDP answer

- `sdpAnswer`: string

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/calls/…/pre-accept \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"sdpAnswer":"string"}'
```

### POST /calls/{id}/accept

Accept an inbound call with the SDP answer

- `sdpAnswer`: string

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/calls/…/accept \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"sdpAnswer":"v=0…"}'
```

### POST /calls/{id}/reject

Reject an inbound call

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/calls/…/reject \
  -H "Authorization: Bearer pk_live_…"
```

### POST /calls/{id}/terminate

Hang up a call

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/calls/…/terminate \
  -H "Authorization: Bearer pk_live_…"
```

## WhatsApp Flows

### GET /flows

List Flows

```bash
curl https://hira.localtechstudio.com/api/v1/flows \
  -H "Authorization: Bearer pk_live_…"
```

### POST /flows

Create a Flow

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/flows \
  -H "Authorization: Bearer pk_live_…"
```

### GET /flows/{id}

Flow details

```bash
curl https://hira.localtechstudio.com/api/v1/flows/… \
  -H "Authorization: Bearer pk_live_…"
```

### PATCH /flows/{id}

Update a Flow

```bash
curl -X PATCH https://hira.localtechstudio.com/api/v1/flows/… \
  -H "Authorization: Bearer pk_live_…"
```

### DELETE /flows/{id}

Delete a Flow

```bash
curl -X DELETE https://hira.localtechstudio.com/api/v1/flows/… \
  -H "Authorization: Bearer pk_live_…"
```

### POST /flows/{id}/publish

Publish a Flow

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/flows/…/publish \
  -H "Authorization: Bearer pk_live_…"
```

## Companies and countries

### GET /companies

List companies

```bash
curl https://hira.localtechstudio.com/api/v1/companies \
  -H "Authorization: Bearer pk_live_…"
```

### POST /companies

Create a company (partner key). From the second company onward, requires `multi_company` (Business plan)

- `name`: string
- `externalRef`: string
- `defaultCountry`: string

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/companies \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"name":"string","externalRef":"string","defaultCountry":"string"}'
```

### PATCH /companies/{id}

Set the company default country (`defaultCountry`, ISO code or dial code, null to go back to the service default). It is used for numbers written without a country code

- `defaultCountry`: string | null

```bash
curl -X PATCH https://hira.localtechstudio.com/api/v1/companies/… \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"defaultCountry":"string"}'
```

### GET /countries

Countries recognised for phone number normalisation (code, name, dial code)

```bash
curl https://hira.localtechstudio.com/api/v1/countries \
  -H "Authorization: Bearer pk_live_…"
```

## API keys

### GET /api-keys

List API keys

```bash
curl https://hira.localtechstudio.com/api/v1/api-keys \
  -H "Authorization: Bearer pk_live_…"
```

### POST /api-keys

Create a key (the secret is shown once, partner key required)

- `scope`: partner | company
- `companyId`: string
- `name`: string

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/api-keys \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"scope":"partner","companyId":"string","name":"string"}'
```

### DELETE /api-keys/{id}

Revoke a key

```bash
curl -X DELETE https://hira.localtechstudio.com/api/v1/api-keys/… \
  -H "Authorization: Bearer pk_live_…"
```

### POST /api-keys/{id}/rotate

Renouveler une clé : une nouvelle clé est créée (secret en clair une seule fois) et l'ancienne reste valable 24 heures (clé partenaire requise)

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/api-keys/…/rotate \
  -H "Authorization: Bearer pk_live_…"
```

## Subscription and billing

### GET /plans

Plans and prices per currency (PROVISIONAL)

```bash
curl https://hira.localtechstudio.com/api/v1/plans \
  -H "Authorization: Bearer pk_live_…"
```

### GET /subscription

Subscription, limits and usage of the account (partner key)

```bash
curl https://hira.localtechstudio.com/api/v1/subscription \
  -H "Authorization: Bearer pk_live_…"
```

### GET /invoices

List invoices (partner key)

```bash
curl https://hira.localtechstudio.com/api/v1/invoices \
  -H "Authorization: Bearer pk_live_…"
```

### GET /invoices/{id}

Invoice details (partner key)

```bash
curl https://hira.localtechstudio.com/api/v1/invoices/… \
  -H "Authorization: Bearer pk_live_…"
```

### GET /invoices/{id}/pdf

PDF of a paid invoice, numbered WA-YYYY-NNNNNN (partner key)

```bash
curl https://hira.localtechstudio.com/api/v1/invoices/…/pdf \
  -H "Authorization: Bearer pk_live_…"
```

### POST /billing/checkout

Start a payment. XAF/XOF/KES → pawaPay (international Mobile Money `phone`, 202). EUR/USD → Stripe (`payment.checkoutUrl`, 201)

- `plan`: string
- `interval`: monthly | yearly
- `currency`: XAF | XOF | KES | EUR | USD
- `extraNumbers`: integer
- `phone`: string
- `successUrl`: string
- `cancelUrl`: string

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/billing/checkout \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"plan":"string","interval":"monthly","currency":"XAF","extraNumbers":0,"phone":"string","successUrl":"string","cancelUrl":"string"}'
```

