# Integration API

> The API your code and no-code tools use - its address, the connection test, every action and list per app, workspaces and errors.

The integration API is what Zapier, Make, n8n and AI assistants use, and you can use it too. Every route, field and answer is in the interactive [API reference](https://nomongeta.zenhalab.com/api/integrations/docs), generated from the code.

## Address and authorization {#base}

```text
https://nomongeta.zenhalab.com/api/integrations/v1
```

Send an [API key](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/integrations/api-keys) with every request (`Authorization: Bearer …`). Requests and answers are JSON; times are ISO 8601 in UTC.

The console's own API (`/api/nomongeta/v1`, see the [REST API](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/developers/rest-api)) works with a signed-in session, for the console's pages. The integration API is the one for keys and other software.

## Start here {#start}

| Request | What it answers |
| --- | --- |
| `GET /me` | Who the key acts as, its scopes and the apps it reaches. The connection test. |
| `GET /event-types` | The events the key may subscribe, each with its JSON Schema and an example. |
| `GET /events/{type}/sample` | Recent events of a type, as delivered ([samples and polling](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/integrations/rest-hooks#samples)). |
| `POST /hooks`, `DELETE /hooks/{id}` | Subscribe and remove [REST hooks](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/integrations/rest-hooks). |

## Actions and lists {#actions}

The same things you'd do in the app, with the same rules: an id from someone else's account always answers `404`.

### Ñomongeta {#actions-nomongeta}

| Request | What it does | Scope |
| --- | --- | --- |
| `GET /nomongeta/flows` | Lists the workspace's flows. | `nomongeta:read` |
| `GET /nomongeta/agents` | Lists the workspace's agents. | `nomongeta:read` |
| `GET /nomongeta/templates` | Lists the workspace's approved WhatsApp templates. | `nomongeta:read` |
| `POST /nomongeta/contacts` | Adds a contact, or updates the one with that address (fields are the workspace's contact variables). | `nomongeta:write` |
| `GET /nomongeta/contacts/find` | Finds a contact by address (phone number or e-mail). | `nomongeta:read` |
| `POST /nomongeta/conversations` | Starts a WhatsApp conversation with an approved template, to a contact who opted in. | `nomongeta:write` |
| `POST /nomongeta/conversations/{conversationId}/messages` | Sends a message in a conversation (free text inside WhatsApp's 24-hour window, a template any time). | `nomongeta:write` |
| `POST /nomongeta/conversations/{conversationId}/flow-runs` | Starts an active flow in a conversation. | `nomongeta:write` |
| `POST /nomongeta/knowledge/documents` | Adds a document to an agent's knowledge. | `nomongeta:write` |

Actions in the workspace act with the role of the admin who created the key, as in the console: lists and finding a contact need the **Viewer** role, adding or updating contacts and sending messages the **Agent** role, starting flows and adding knowledge the **Builder** role.


### Sending messages {#send-message}

`POST /nomongeta/conversations/{conversationId}/messages` writes in an existing conversation, shown in the inbox as coming from your integration. On WhatsApp, free text is only allowed within **24 hours** of the contact's last message (`409 outside_window` otherwise); an approved template can be sent at any time. A conversation a teammate has taken over stays theirs.

### Starting a WhatsApp conversation {#start-conversation}

`POST /nomongeta/conversations` writes first to a contact who hasn't messaged you, with an approved template (`templateId` + `params`): WhatsApp lets a business start only that way. It goes out from the template's number, and the conversation belongs to that number's agent; when the contact answers, the number's flow or agent carries on. A live conversation with them on that number is reused (`created: false`).

WhatsApp also requires that the person agreed to hear from you. Send `optIn: true` when you collected that agreement (a form, a checkout box), or record it beforehand with `optedIn: true` when you add or update the contact (`false` withdraws it). Without it the call answers `409 not_opted_in` and nothing is sent. A contact who replies with just SAIR, PARAR or STOP has their opt-in withdrawn.

## Signing in with OAuth {#oauth}

Apps we registered (Zapier, n8n) can also connect by signing in, with OAuth 2.0 and PKCE, instead of a pasted key. Their token acts as the person: personal apps directly, and the Ñomongeta workspaces they can open by naming one in the `X-Workspace-Id` header (`GET /me` lists them). The person's role in that workspace applies.

## Errors {#errors}

Errors answer `{ "error": "<code>", … }` with the fields that explain it. The common ones are under [API keys](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/integrations/api-keys#errors); actions add their own, like `outside_window`, `run_active` (another flow is running in that conversation) or `handed_off`. The [reference](https://nomongeta.zenhalab.com/api/integrations/docs) lists them per route.
