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

# Messaging apps REST reference

> The /api/v2/messaging-apps account routes behind the messaging apps setup pane: app definitions, install locations, credentials and identity links.

This page is a contract reference for the v2 account routes behind the
**Settings → Messaging apps** pane. V3 has no tool for these routes yet. The
setup steps for each provider are in
[Talk to Apostra in Slack, Teams, Discord, or WhatsApp](https://docs.apostra.com/v3/messaging-apps.md).

## Routes

The `/api/v2/messaging-apps` routes below are the public account REST surface
behind the secure setup pane (**Settings → Messaging apps**, reached from the
Listing page's Distribution tabs for seller accounts). They provision
customer-owned apps, install locations, credentials, and identity links. They
are separate from the provider-facing webhook endpoints returned during
provisioning.

Every account endpoint requires a directly authenticated, active administrator
from a human WorkOS-backed Apostra session and an account enrolled in the
messaging-apps pilot, with one exception: [checking shared Slack
availability](https://docs.apostra.com/v3/messaging-apps.md#check-shared-slack-availability) is not pilot-gated. API keys,
service tokens, simulated sessions, staff impersonation, and a linked provider
identity are not administrator credentials for this surface. Requests are
scoped to the administrator's authenticated account; `definitionId` and
`installationId` are UUIDs. An account that is not enrolled receives
`FEATURE_NOT_ENABLED` (HTTP 403), which is an availability result rather than
an empty app list.

Provider and Apostra authentication stay distinct:

| Boundary | Authentication contract |
| - | - |
| Account REST routes | Human WorkOS-backed Apostra session, current active administrator membership, and pilot enrollment. Do not call these routes with an Apostra API key or provider token. |
| Discord interactions and Gateway | Discord HTTP requests must have a valid Ed25519 signature for the definition's required public key. The required bot token is verified against the exact application and powers the Gateway and installed-app delivery. The Gateway requests only `GUILDS` and `GUILD_MESSAGES`; Discord's direct-message and explicit-mention exceptions provide the admitted content without the privileged Message Content intent. |
| Microsoft Teams activities | Microsoft bearer tokens must have the expected issuer and the definition's exact application ID as audience. The required client secret and application-tenant setting belong to that same Azure Bot registration. |
| WhatsApp callbacks and replies | Webhook verification uses the required verify token; event delivery must have a valid `X-Hub-Signature-256` for the required app secret. The required system-user access token is used only for Cloud API replies. WhatsApp remains reply-only inside the current user-initiated service window. |

Provider credentials are supplied only in create or rotation request bodies,
encrypted at rest, and never returned. The webhook paths do not accept an
Apostra administrator session as a substitute for provider authentication.

### Inspect configured apps

`GET /api/v2/messaging-apps/discord`, `GET /api/v2/messaging-apps/teams`, and
`GET /api/v2/messaging-apps/whatsapp` each return `{ definitions: [...] }` for one
provider. The result is sanitized: it never contains provider credentials, raw
provider actor IDs or their digests, message content, or webhook payloads.

| Response field | Meaning |
| - | - |
| `definitions[].definition.id` | App-definition UUID. |
| `definitions[].definition.customerId` | Owning Apostra account ID. |
| `definitions[].definition.agentKey` | Agent configured for the app. |
| `definitions[].definition.brand` | App identity: required `displayName`, `supportUrl`, and `privacyPolicyUrl`; optional `shortDescription`, six-digit `accentColor`, `iconAssetId`, and `termsUrl`. Legal URLs are HTTPS. |
| `definitions[].definition.providerRef` | Provider registration reference. Discord and Teams return `provider` and `applicationId`; WhatsApp returns `provider`, `businessAccountId`, and `phoneNumberId`. |
| `definitions[].definition.status` | `draft`, `active`, or `retired`. |
| `definitions[].credentialConfigured` | Whether the required provider credentials are present; credentials themselves are never returned. |
| `definitions[].installations[]` | Approved provider locations for this definition. |
| `installations[].installation` | Installation UUID, parent `appDefinitionId`, `customerId`, provider-specific `providerRef`, `status` (`active`, `suspended`, or `uninstalled`), and `installedAt`. Discord references `installContext` (`guild` or `user`) and `ownerId`; Teams references `tenantId` and a `personal`, `team`, or `channel` location; WhatsApp references its business-account and phone-number IDs. |
| `installations[].credentialConfigured` | Whether the installation can use the definition's required credentials. |
| `installations[].identityBindings[]` | The linked Apostra person: opaque `bindingId` (used to revoke that exact link), `userId`, `userEmail`, `userName`, `linkedByUserId`, nullable `permissionLevel`, `membershipActive`, `status` (`active` or `revoked`), `verifiedAt`, and nullable `revokedAt`. This intentionally identifies Apostra membership, not the provider actor ID. |
| `installations[].conversationBindings` | Content-free conversation counts: `total`, `direct`, `channel`, and nullable `lastBoundAt`. |
| `installations[].inboundReceipts` | Content-free inbound counts: `received`, `processing`, `completed`, `ignored`, `failed`, and nullable `lastReceivedAt`. |
| `definitions[].interactionEndpoint` | Discord-only HTTPS path to configure in the Discord Developer Portal. |
| `definitions[].messagingEndpoint` | Teams-only HTTPS messaging endpoint. |
| `definitions[].webhookEndpoint` | WhatsApp-only HTTPS callback endpoint. |

### Create an app definition

Use `POST /api/v2/messaging-apps/discord`, `POST /api/v2/messaging-apps/teams`, or
`POST /api/v2/messaging-apps/whatsapp`. Each response returns `definition` (the
sanitized definition above) and the provider-specific endpoint
(`interactionEndpoint`, `messagingEndpoint`, or `webhookEndpoint`). The request
body is strict: do not send fields for another provider.

| Endpoint | Required provider fields |
| - | - |
| `POST /api/v2/messaging-apps/discord` | `applicationId` (15–22 digit Discord ID), 64-character hexadecimal `publicKey`, and `botToken` (32–2,048 characters). |
| `POST /api/v2/messaging-apps/teams` | UUID `applicationId`, UUID `applicationTenantId` or `organizations`, and `clientSecret` (16–4,096 characters). |
| `POST /api/v2/messaging-apps/whatsapp` | Numeric `businessAccountId` and `phoneNumberId` (6–32 digits), `appSecret` (16–4,096 characters), `accessToken` (32–8,192 characters), `webhookVerifyToken` (32–512 characters), and a `graphApiVersion` such as `v24.0`. |
| Every create request | `brand`: required non-empty `displayName` (up to 80 characters), `supportUrl`, and `privacyPolicyUrl`; optional `shortDescription` (up to 200 characters), `accentColor` (`#RRGGBB`), `iconAssetId`, and `termsUrl`. URLs must use HTTPS. |

Provider secrets are accepted only in the request, encrypted, and never
returned by any endpoint. Replacing an app definition does not turn it into a shared
app; each definition is the customer's own provider registration.

### Register and manage locations

After configuring the endpoint with the provider, register each permitted
location with one of the following strict request bodies. Each successful
registration returns `{ installation }`, using the installation fields in the
inspection table above.

| Endpoint | Request fields |
| - | - |
| `POST /api/v2/messaging-apps/{definitionId}/discord-installations` | `installContext` (`guild` or `user`) and 15–22 digit Discord `ownerId`. |
| `POST /api/v2/messaging-apps/{definitionId}/teams-installations` | UUID `tenantId` and `location`: `{ kind: "personal", userId }`, `{ kind: "team", teamId }`, or `{ kind: "channel", teamId, channelId }`. Each ID is a non-empty provider ID. |
| `POST /api/v2/messaging-apps/{definitionId}/whatsapp-installations` | `{}`. The definition's registered business number is the one permitted location. |
| `PATCH /api/v2/messaging-apps/{definitionId}/installations/{installationId}` | `{ status: "suspended" }` to stop new work while retaining the record, or `{ status: "uninstalled" }` to remove the location. Returns `{ installation }`. |

Suspending or uninstalling a location stops new inbound work and revokes saved
proactive targets. A Teams removal event also suspends its matching installation
automatically; the control does not depend on a provider token continuing to
work after removal.

### Link or revoke a person

`PUT /api/v2/messaging-apps/{definitionId}/installations/{installationId}/identity`
links one provider actor to an active member of the authenticated account. Send
the strict body `{ externalActorId, userId }`, where `externalActorId` is the
trimmed provider user ID (1–255 characters) and `userId` is a positive
Apostra member ID. It returns `{ linked: true, userId }`.

The secure setup pane lists each linked Apostra person, email, membership
state, and link status so an administrator can audit who has access. It
deliberately does not display the raw provider user ID: that identifier is not needed for
routine access review and must not be exposed through a diagnostic response.
Each audited link instead carries an opaque `bindingId`. To remove that exact
mapping, send `DELETE /api/v2/messaging-apps/{definitionId}/installations/{installationId}/identity`
with `{ bindingId }`; the server scopes the handle again to the authenticated
account, definition, installation, and provider before revoking it. Clients
that do not have the audit response may continue to send `{ externalActorId }`
instead. Send exactly one selector. The response is `{ revoked: boolean }`; the
next provider interaction fails closed before the agent runs.

### Rotate credentials or retire an app

The secure setup pane offers both controls directly on each branded app:
**Rotate credentials** opens the same credential fields used at setup (never
prefilled — the pane never displays an existing secret), and **Retire app**
asks for confirmation before it stops the app for good. Both need an account
administrator; the REST calls behind them are:

`PUT /api/v2/messaging-apps/{definitionId}/credentials` replaces credentials and
returns `{ definition, rotated: true }`. Its strict body declares `provider`
and only that provider's credential fields:

| Provider | Credential request fields |
| - | - |
| `discord` | 64-character hexadecimal `publicKey` and `botToken` (32–2,048 characters). |
| `teams` | UUID `applicationTenantId` or `organizations`, plus `clientSecret` (16–4,096 characters). |
| `whatsapp` | `appSecret` (16–4,096 characters), `accessToken` (32–8,192 characters), `webhookVerifyToken` (32–512 characters), and `graphApiVersion` such as `v24.0`. |

To retire the entire app, send `PATCH /api/v2/messaging-apps/{definitionId}` with
`{ status: "retired" }`. It returns `{ definition }`. Retirement prevents new
work for the app; use the location controls when only one provider location
should stop.

### Pause an active app

The pilot enrollment flag makes the secure setup pane and the account API
available; it is not a runtime stop for an app that is already installed. Keep
the account enrolled while an administrator applies a lifecycle control.

* To stop one location, suspend its installation in the secure setup pane, or
  send `PATCH /api/v2/messaging-apps/{definitionId}/installations/{installationId}`
  with `{ status: "suspended" }`. New inbound work stops at that location and
  its saved proactive targets are revoked.
* To stop every location for a branded app, select **Retire app** in the
  secure setup pane and confirm, or send
  `PATCH /api/v2/messaging-apps/{definitionId}` with `{ status: "retired" }`.
  New work for that definition stops and its credentials are queued for cleanup.

After either action, refresh the provider list and confirm the expected
`suspended`, `uninstalled`, or `retired` state. If an account was removed from
the pilot before this action, an administrator must have its enrollment restored
first so that they can apply the lifecycle control. Do not remove provider
credentials as an emergency stop; use the audited lifecycle controls.

### Check shared Slack availability

`GET /api/v2/messaging-apps/slack` returns `{ available: boolean, installUrl:
string | null }` for the shared Apostra Slack app described in [Open
messaging destinations](https://docs.apostra.com/v3/messaging-apps.md#open-messaging-destinations). Unlike every other
endpoint on this page, it does not require the account to be enrolled in the
messaging-apps pilot: the shared Slack app is not a pilot feature, so any
authenticated member of the account can read whether it can be installed right
now. `available` is `true`, with `installUrl` set, only once Apostra's
shared Slack app is publicly available; otherwise `installUrl` is `null` and
the secure setup pane shows **Coming soon** instead of a working link.


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