# Connect your organisation

Use an organisation-owned OAuth client to connect your backend to your organisation's contacts and webhook subscriptions. You don't need a user login, consent screen, redirect URI, or refresh token.

Create and manage named clients in the Tapt dashboard under **account menu → Settings → Integrations → API access**. Each client belongs to the selected organisation and can access only that organisation's data.

Existing Zapier connections use their existing delegated OAuth flow. You don't need to replace or reconnect them to use this guide.

## Before you begin

You must be an organisation admin, and your organisation must have an active platform subscription. Other organisation roles can't manage API clients.

Have a server-side secret store ready. Don't put OAuth secrets or webhook signing keys in browser code, mobile apps, source control, or logs.

## Provision a client

1. Open the account menu, then **Settings → Integrations → API access** for the organisation you want to connect.
2. Select **Create client** and enter a descriptive **Client name**, such as `CRM integration`, up to 80 characters.
3. Select the **Approved scopes** your integration needs. **Read organisation contacts** is selected by default. Select **Manage webhook subscriptions** as well if needed.
4. Select **Create client**, review the name and scopes in the confirmation dialog, then confirm with **Create client**.
5. Copy the **OAuth client secret** into your server's secret store. It appears only once and can't be retrieved later. Check **I have copied and securely stored this client secret.** before closing.
6. Save the **Client ID**, **Token endpoint**, and **Webhook signing key** from **Credentials**. Use **Reveal** or **Copy** for the signing key.

Use **Manage** beside a client to reopen its credentials and lifecycle controls. If you lose the OAuth secret, rotate it to get a new one. The webhook signing key remains retrievable in **Manage**; it isn't a one-time OAuth secret.

| Scope   | Allows                                                                             |
| ------- | ---------------------------------------------------------------------------------- |
| `read`  | Read organisation contacts and list or retrieve the client's webhook subscriptions |
| `write` | Create, update, and delete the client's webhook subscriptions                      |

`write` doesn't include `read` and doesn't allow contact creation or editing. Select both scopes if your integration needs both. Each organisation can have **five active clients**. Revoke an unused client before creating a sixth.

After setup, [request an access token](#request-an-access-token), [read contacts](#read-contacts), or [subscribe to signed webhooks](#subscribe-to-signed-webhooks) using the examples below.

### Dashboard-authenticated provisioning API

The provisioning API accepts this request body when creating a client:

```json
{
  "oauth_client": {
    "name": "CRM integration",
    "scopes": ["read", "write"]
  }
}
```

The signing key is separate from the OAuth credential and is shared by all subscriptions belonging to this client. Authorised admins can retrieve it again through the client list API or **Manage** in Settings. Responses containing keys use `Cache-Control: no-store`; list responses never disclose OAuth client secrets.

Omitted provisioning scopes default to `read`; empty or unsupported scope lists are rejected.

The dashboard-authenticated provisioning endpoints are separate from the OAuth resource API. Organisation OAuth tokens cannot call them.

| Method | Endpoint                                                                | Action                                                             |
| ------ | ----------------------------------------------------------------------- | ------------------------------------------------------------------ |
| GET    | `/api/organisations/{id}/oauth/clients`                                 | List client metadata and webhook signing keys, never OAuth secrets |
| POST   | `/api/organisations/{id}/oauth/clients`                                 | Create a client with the body above                                |
| POST   | `/api/organisations/{id}/oauth/clients/{client_id}/secrets`             | Rotate a secret with a 24-hour overlap                             |
| DELETE | `/api/organisations/{id}/oauth/clients/{client_id}/secrets/{secret_id}` | Revoke an old secret                                               |
| DELETE | `/api/organisations/{id}/oauth/clients/{client_id}`                     | Revoke a client and its issued tokens                              |

`client_id` in these paths is the public client identifier. Client management is rate limited. See [Rate limits](/docs/rate-limits) for retry behaviour.

## Request an access token

Replace the example credentials with your client's credentials. Keep them on your server, not in a browser or mobile app.

```bash
curl --request POST 'https://api.cards.tapt.io/oauth/token' \
  --header 'Content-Type: application/json' \
  --data '{"grant_type":"client_credentials","client_id":"YOUR_CLIENT_ID","client_secret":"YOUR_CLIENT_SECRET","scope":"read write"}'
```

You can also use HTTP Basic with a form-encoded body:

```bash
curl --request POST 'https://api.cards.tapt.io/oauth/token' \
  --user 'YOUR_CLIENT_ID:YOUR_CLIENT_SECRET' \
  --data-urlencode 'grant_type=client_credentials' \
  --data-urlencode 'scope=read write'
```

Use one authentication method per request. Don't combine Basic with body credentials or send credentials in the query string. An invalid Authorization header doesn't fall back to body credentials.

The response contains `access_token`, `token_type`, `expires_in: 3600`, and the granted `scope`. Request only approved scopes. Omit `scope` to request all scopes approved for your client.

Cache the token until near expiry, then repeat the client-credentials request. This flow doesn't issue refresh tokens. [Rate limits](/docs/rate-limits) apply, so don't request a new token for each API call.

## Read contacts

Send the access token as a Bearer token. Your token needs `read` scope.

```bash
curl 'https://api.cards.tapt.io/oauth/api/contacts?page=1&per_page=25' \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN'
```

The response is a contact array. `contact_owner_email` identifies the card/profile owner's email when available; it can be null. The API doesn't filter contacts by creation time.

Organisation-owned clients default to 25 contacts per page and cap positive `per_page` values at 100. `page_size` is an alias; `per_page` takes precedence if both are supplied. Pages must be between 1 and 10,000, with a default of 1. Zero, negative, fractional, or malformed values return `400` with `invalid_pagination`. Existing legacy clients, including Zapier, retain their `page_size` parameter and default of 50.

See [Rate limits](/docs/rate-limits) before scheduling polls or imports.

## Subscribe to signed webhooks

Request a token with `write` scope. Configure your webhook receiver with the client's `webhook_signing_key`, saved when you provisioned the client. Don't use the OAuth client secret to verify webhooks.

Create the subscription without a signing-key field:

```bash
curl --request POST 'https://api.cards.tapt.io/oauth/webhooks/subscriptions' \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{"event_type":"contact.created","target_url":"https://crm.example.com/tapt/webhook"}'
```

The response wraps the subscription in `data`. List responses are arrays. Subscription responses never disclose the signing key. Save the numeric subscription ID to update or delete it later. Organisation subscriptions reject per-subscription `secret` overrides.

All organisation-client deliveries use the client's signing key automatically. Each client has a different generated 256-bit key, shared across its subscriptions. Supported events are `contact.created` and `contact.updated`; the body is the contact object, not an event envelope. Existing legacy subscriptions retain their existing optional per-subscription signing keys.

Subscription URLs must be public HTTPS destinations. Client and organisation ownership can't change. Delivery checks your client's active status, organisation, approved `write` scope, and subscription activity and expiry. Revoking the client stops subsequent delivery checks from succeeding.

Read [Webhook delivery](/docs/webhook-delivery) for a sample payload, signature-verification code, acknowledgement requirements, retries, and recovery from missed events. Verify signatures before processing and make CRM updates idempotent.

## Rotate or revoke credentials

### Rotate an OAuth secret

1. Under **API access**, select **Manage** beside the client.
2. Select **Rotate secret**, then confirm **Rotate secret** in the confirmation dialog.
3. Copy and securely store the new one-time OAuth secret, then acknowledge that you saved it.
4. Switch your integration to the new secret and verify that it can request a token.
5. Select **Revoke old secret** for the previous secret, then confirm the revocation, or let it expire at the displayed time.

Rotation gives the previously non-expiring secret a **24-hour overlap**. Secrets already marked **Expiring** keep their existing deadlines; another rotation doesn't extend them. The new secret works immediately. Revoking an old secret stops new token issuance with that secret, but already-issued access tokens remain valid until expiry or revocation. You can't revoke the last usable secret on its own.

OAuth secret rotation doesn't change the client ID, approved scopes, or persistent webhook signing key. Each client has its own signing key, shared across that client's subscriptions. Signing-key rotation isn't available in Settings or through the API.

### Revoke a client or token

To stop all access for an integration, select **Manage → Revoke client** and confirm **Revoke client**. This can't be undone. Revocation disables its credentials and issued access tokens immediately and blocks subsequent webhook deliveries. It can't recall a webhook request already in flight. A revoked client no longer counts toward the five-active-client limit.

To revoke one organisation-client access token, call `POST /oauth/revoke` using HTTP Basic and a form-encoded `token` field. It returns an empty 200 response for unknown tokens or tokens owned by another client without affecting that client. This endpoint doesn't change existing Zapier disconnect behavior.

For endpoint schemas, see the [API reference](/api/authentication).
