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

# Connect

Connect your own https endpoint to a profile with its URL, optional headers and a signing secret, then send it a test event.

A custom endpoint is connected with its URL. Zernio posts a test event to it before saving anything, and returns the secret every request is signed with.

## Connect with a URL

Send the URL for a profile, with the headers your endpoint expects:

```bash
curl -X POST "https://zernio.com/api/v1/connect/custom-endpoint/credentials" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "profileId": "PROFILE_ID",
    "url": "https://example.com/zernio/conversions",
    "headers": { "Authorization": "Bearer YOUR_ENDPOINT_TOKEN" }
  }'
```

```json
{
  "accountId": "6507a1b2c3d4e5f6a7b8c9d0",
  "endpointId": "ep_3f9c1a7b2d4e6f8091a2b3c4",
  "accountName": "example.com",
  "signingSecret": "whsec_KCkqKywtLi8wMTIzNDU2Nzg5Ojs8PT4/QEFCQ0RFRkc="
}
```

| Field | What it is |
|-------|------------|
| `url` | The https URL the conversions are POSTed to, on port 443 (or 8443). No user or password in it. Required. |
| `headers` | Up to 10 headers sent with every request, such as `Authorization: Bearer <token>` or `X-Api-Key`. Stored encrypted. Optional. |
| `signingSecret` | The secret requests are signed with: `whsec_` and 24 to 64 base64-encoded bytes. Optional: Zernio keeps the endpoint's current one, or makes a `whsec_…` secret. |
| `name` | A display name, up to 100 characters. Optional: Zernio uses the URL's host. |

Keep the `signingSecret` from the response: your endpoint needs it to [verify every request](/platforms/custom-endpoint/conversions#verify-the-signature).

In the dashboard, open **Connections**, pick **Custom endpoint** and enter the same fields.

## Send a test event

`POST /v1/accounts/{accountId}/custom-endpoint/test` posts one test event, signed like every delivery, and returns what the endpoint answered:

```bash
curl -X POST "https://zernio.com/api/v1/accounts/ACCOUNT_ID/custom-endpoint/test" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```

```json
{ "delivered": true, "statusCode": 200 }
```

When the endpoint did not take it, `delivered` is `false`, `error` says why, and `statusCode` is `null` if it never answered.

## How it behaves

- The test event has `test: true`, `testCode: "ZERNIO_TEST"`, an `eventId` of `zernio_test_<unix time>`, and is a `Purchase` worth 1 USD. Nothing is stored.
- The URL must resolve to a public address. Private, loopback, link-local, CGNAT and cloud metadata addresses are refused, checked again on every request.
- Redirects are never followed: save the final URL.
- Zernio sets `Content-Type`, `User-Agent`, `Host`, `Content-Length` and the `webhook-*` headers itself. Your headers cannot replace them.
- A profile can hold many endpoints, one connection per URL. Connecting the same URL again replaces its headers and keeps its signing secret, which the response returns again.
- The endpoint is the connection's only destination. `GET /v1/ads/conversions/destinations` lists it, with the `endpointId` as its id.

## If it fails

| Error | Cause | Fix |
|-------|-------|-----|
| `400` with `invalid_field_value` on `url` | The URL is not https, has a user or password, resolves to a private address, redirects, or did not answer the test event with a 2xx. Nothing was saved | Read the reason in the message, fix the endpoint and connect again. |
| `400` on `headers` | More than 10 headers, or a header Zernio sets itself | Send at most 10 of your own headers. |
| `402` | The account cannot connect more accounts on its plan | Upgrade the plan or remove an account. |
| `403` | The Ads add-on is off | Turn on the Ads add-on, then connect. |

## Related

- [Connect a custom endpoint](/connect/connect-custom-endpoint-credentials)
- [Send a test event to a custom endpoint](/conversions/test-custom-endpoint)
- [List conversion destinations](/conversions/list-ad-conversion-destinations)
- [Conversions](/platforms/custom-endpoint/conversions)