> Documentation index: https://docs.zernio.com/llms.txt. Every page is also Markdown: add .md to its URL.

# Connect a custom endpoint API Reference

Connect your own HTTP endpoint as a conversions destination. It then works like any other destination: `GET /v1/ads/conversions/destinations` lists it, forwarding rules send to it with their filters, value rules, dedup and consent, and every send shows in the delivery log.

The `url` must use https, resolve to a public address (private, loopback, link-local and cloud metadata addresses are refused, on every request) and answer without redirecting: redirects are never followed.

Before saving, Zernio posts a test event (`test: true`) to the URL. Nothing is saved unless the endpoint answers it with a 2xx.

Every request is a JSON batch of up to 100 events:

- Signed the Standard Webhooks way: `webhook-id`, `webhook-timestamp` and `webhook-signature` (`v1,` and the base64 HMAC-SHA256 of `{webhook-id}.{webhook-timestamp}.{body}`, keyed with the signing secret).
- Emails, phone numbers, external ids, names and addresses arrive SHA-256 hashed after Meta's and Google's normalization.
- A 429, a 5xx or no answer is retried. A 2xx body `{"rejected":[{"eventId":"...","message":"..."}]}` fails just those events.

One connection per URL in a profile: connecting the same URL again replaces its headers and keeps its signing secret, which the response returns again.

Requires the Ads add-on.


## POST /v1/connect/custom-endpoint/credentials

**Connect a custom endpoint**

Connect your own HTTP endpoint as a conversions destination. It then works like any other destination: `GET /v1/ads/conversions/destinations` lists it, forwarding rules send to it with their filters, value rules, dedup and consent, and every send shows in the delivery log.

The `url` must use https, resolve to a public address (private, loopback, link-local and cloud metadata addresses are refused, on every request) and answer without redirecting: redirects are never followed.

Before saving, Zernio posts a test event (`test: true`) to the URL. Nothing is saved unless the endpoint answers it with a 2xx.

Every request is a JSON batch of up to 100 events:

- Signed the Standard Webhooks way: `webhook-id`, `webhook-timestamp` and `webhook-signature` (`v1,` and the base64 HMAC-SHA256 of `{webhook-id}.{webhook-timestamp}.{body}`, keyed with the signing secret).
- Emails, phone numbers, external ids, names and addresses arrive SHA-256 hashed after Meta's and Google's normalization.
- A 429, a 5xx or no answer is retried. A 2xx body `{"rejected":[{"eventId":"...","message":"..."}]}` fails just those events.

One connection per URL in a profile: connecting the same URL again replaces its headers and keeps its signing secret, which the response returns again.

Requires the Ads add-on.


### Request Body

- **url** (required) `string`: The https URL the conversions are POSTed to, on port 443 (or 8443). No user or password in it.
- **headers** `object`: Headers sent with every request, such as `Authorization: Bearer <token>` or `X-Api-Key`. Stored encrypted. `Content-Type`, `User-Agent`, `Host` and the `webhook-*` headers are set by Zernio and cannot be replaced.
- **signingSecret** `string`: The secret requests are signed with: `whsec_` and 24 to 64 base64-encoded bytes, the Standard Webhooks format. Leave it out to keep the endpoint's current one, or to have Zernio make one.
- **name** `string`: Optional display name. Defaults to the URL's host.
- **profileId** (required) `string`: Your Zernio profile ID
- **state** `string`: Optional state passthrough for the connect flow.
- **redirect_url** `string`: Optional URL to redirect to after a successful connection, echoed back as redirectUrl.

### Responses

#### 200: Custom endpoint connected

**Response Body:**

- **accountId** `string`: No description
- **endpointId** `string`: The destination id forwarding rules send to (`ep_...`).
- **accountName** `string`: No description
- **signingSecret** `string`: The secret every request is signed with.
- **redirectUrl** `string`: No description

#### 400: Invalid request, or the endpoint did not accept the test event (code invalid_field_value, param url, with the reason).

#### 401: Unauthorized.

#### 402: Payment method or enterprise contract required: the authenticated account hit a billing gate before the connection could proceed. Switch on `reason` to render the right prompt:

- `free_tier_exceeded`: the team has connected more accounts than the free tier allows. Add a payment method to continue (billed per additional connected account).
- `twitter_passthrough`: connecting an X account requires a card on file, even the 1st one, because X API calls are passed through per call. Prepaid-balance accounts never get it: they pay X calls from the balance.
- `enterprise_required`: the team's enterprise contract sets a connected-account cap and it has been reached. Self-service teams have NO cap (the $1/account rate continues at any scale). The user already has a card on file; this gate is about contract terms.
- `card_verification_required`: the card on file was flagged at add time (prepaid, or issued in a different country than the billing address). A one-time verification charge of `details.verification_amount_cents` (USD) is pending; it is credited to the team's usage balance, not a fee.
- `workspace_billing_required`: the profile belongs to a workspace that has no billing set up yet. `details.workspace_id` names it; billing is set up for that workspace in the dashboard.

**What to do:** redirect the end-user to `dashboard_url`.

- `free_tier_exceeded`, `twitter_passthrough`, `card_verification_required`: it opens the Zernio billing page (the add-payment-method drawer, or the verification step). The request succeeds once the card is on file (or verified, or paid).
- `enterprise_required`: it opens the enterprise contact form (not the billing tab), to adjust the contract's limit.


**Response Body:**

- **error** (required) `string`: Human-readable error message suitable for end-user display. (example: "X (Twitter) requires a payment method due to API pass-through costs. Add a payment method to connect an X account.")
- **code** (required) `string`: Machine-readable error code. Stable across versions. - one of: PAYMENT_REQUIRED
- **reason** (required) `string`: Discriminator for which gate fired. - one of: free_tier_exceeded, twitter_passthrough, enterprise_required, card_verification_required, workspace_billing_required
- **documentation_url** `string` (uri): Link to the relevant documentation page. (example: "https://docs.zernio.com/pricing/payment-method-required")
- **dashboard_url** `string` (uri): Deep-link to send the end-user to. For
`free_tier_exceeded` and `twitter_passthrough` this opens
the add-payment-method drawer on the Zernio billing page.
For `enterprise_required` this is the Zernio enterprise
contact page.
 (example: "https://zernio.com/dashboard/billing?add_payment_method=1")
- **details** `object`: Structured context for SDK clients that want to render their own UX. Keys vary by `reason`.
  - **free_tier_account_limit** `integer`: How many accounts the free tier allows. Only set when reason=free_tier_exceeded. (example: 2)
  - **current_account_count** `integer`: How many accounts the team currently has connected. Set when reason=free_tier_exceeded or reason=enterprise_required. (example: 5)
  - **has_payment_method** `boolean`: Whether the team currently has a card on file in Stripe. Set when reason=free_tier_exceeded or reason=twitter_passthrough.
  - **can_add_card** `boolean`: Whether the caller can add the card themselves (the payer, or an owner, admin or billing admin of the workspace). False for a member or a viewer: the workspace owner has to add it. Set for the card reasons.
  - **verification_amount_cents** `integer`: One-time card verification charge in USD cents, credited to usage. Only set when reason=card_verification_required. (example: 1000)
  - **effective_account_limit** `integer`: The negotiated connected-account cap from the
team's enterprise contract. Self-service teams
have no cap and never receive this reason. Only
set when reason=enterprise_required.
 (example: 2000)

#### 403: Ads add-on required.

---