OSPRY Docs

Developers

Authenticating with the OSPRY API

Who this is for: Developers sending contacts to OSPRY or connecting a CRM · Where: Portal -> Reach -> Inbound Integrations (/integrations/inbound)

What this does

Your systems prove who they are to OSPRY with a tenant API key or, for the generic inbound webhook, a per-source token. This guide covers how to create, send, rotate and revoke those credentials, what each error means, and how CRM connections authenticate.

API access is part of the Starter plan and up. Only owners, admins and agency admins can create or change keys.

Hosts

OSPRY serves its API from two hosts. Use the right one for each call.

Host What it serves
https://{customerPublicId}.lgnapi.com Pushes: POST /v1/contacts, POST /v1/contacts/{sourceId} and POST /v1/contacts/highlevel. This is the canonical host for pushes.
https://app.ospry.ai POST /api/contacts/links and GET /api/v1/schema. It also still accepts the older push paths, POST /api/contacts and POST /api/contacts/webhook/{sourceId}, during the move to the host above.

{customerPublicId} is your account's public ID. The portal shows your full host under Send contacts here on Inbound Integrations. The API reference documents every endpoint.

Steps

  1. Open Reach -> Inbound Integrations and find API keys.

  2. Enter a New key name, such as "Production CRM push".

  3. Under Scopes, leave contacts:write on. Tick contacts:links:write only if this key will create tracking links.

  4. Click + New key.

  5. Copy the key right away. OSPRY shows it once and cannot show it again.

  6. Store it in a secret manager or environment variable on your server, never in browser code.

  7. Send it on every request:

    curl -X POST "https://{customerPublicId}.lgnapi.com/v1/contacts" \
      -H "Authorization: Bearer $OSPRY_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"contacts":[{"email":"jane@acme.com","externalId":"crm-123","firstName":"Jane","company":"Acme"}]}'
    

    A successful push returns 202 Accepted.

API keys

Key format

A key looks like lsk_ followed by 43 random characters. OSPRY stores only a hash of it.

The Key column on the keys list shows the key prefix: lsk_ plus the first 8 random characters. The prefix tells your keys apart. It cannot be used to authenticate, and it is safe to log.

Sending a key

Send the key in one of two headers:

  • Authorization: Bearer <key> (checked first)
  • x-api-key: <key>

An Authorization header with a scheme other than Bearer is ignored, and OSPRY then looks for x-api-key.

Scopes

Scope Granted Allows
contacts:write Always, on every key Pushing contacts and posting to the inbound webhook paths.
contacts:links:write Only when you tick it at creation POST /api/contacts/links, which creates tracking links.

You cannot add a scope to an existing key. Create a new key with the scopes you need, move your system to it, then revoke the old one.

Rotation

Click Rotate next to a key to replace it.

  • OSPRY creates a new key with the same name and scopes, and shows it once.
  • The old key keeps working for 24 hours. The portal shows the exact time it stops.
  • Rotating the same key again does not extend that deadline.

Revocation

Click Revoke to stop a key right away. Requests with it then fail with 401. Revoking a key that was just rotated also ends its 24-hour grace period immediately. Use this if a key leaks. OSPRY keeps a record of the revoked key, and it stays on the list marked as revoked.

Errors

Auth errors have this JSON body:

{"ok": false, "error": "unauthorized"}
Status error Meaning Fix
401 unauthorized OSPRY does not accept this credential. See the list below.
403 forbidden The key is valid but lacks the scope this call needs. On the lgnapi.com host, it also means the key belongs to a different account than the host. Create a key with the right scope, and use your own account's host.
403 api_access_required The key is valid, but your plan does not include API access. Returned by https://app.ospry.ai only. Move to a plan that includes API access.
429 rate limited Too many requests. The Retry-After header says how many seconds to wait. See Rate limiting.

OSPRY returns the same 401 for every credential problem, so the response never reveals which check failed. A 401 can mean:

  • The key is wrong, incomplete or blank.
  • The key was revoked, or its rotation grace period ended.
  • The key has expired.
  • Your plan no longer includes API access. See below.

When the plan loses API access

If your account moves to a plan without API access, your keys and source tokens stop working. They are kept, and they work again when the plan includes API access again. The same key gets a different error on each host:

  • On https://{customerPublicId}.lgnapi.com: 401 unauthorized, because that host no longer recognizes the key.
  • On https://app.ospry.ai, including POST /api/contacts/links: 403 with {"ok": false, "error": "api_access_required"}.

So if a key that used to work suddenly returns 401, check your plan as well as whether the key was revoked or rotated.

On https://app.ospry.ai, the plan check runs before the scope check. A key on a plan without API access gets api_access_required even if it also lacks the scope.

Portal session fallback on /api/contacts

POST /api/contacts on https://app.ospry.ai accepts either an API key or a signed-in portal session.

  • A key header is present: OSPRY uses the key only. If the key is wrong, blank or not allowed, the request fails with 401 or 403. It never falls back to the session.
  • No key header is present: OSPRY uses the portal session in the browser making the call. With no session, the request fails with 401.

The session path exists for the portal's own pages. Third-party integrations must always send a key.

Per-source tokens for the generic inbound webhook

Tools such as Zapier, Make or n8n can post contacts to a dedicated webhook URL instead of using an API key.

  1. On Inbound Integrations, register a webhook source under Connections.

  2. Copy the token OSPRY shows. It starts with lswh_ and is shown once.

  3. Post to https://{customerPublicId}.lgnapi.com/v1/contacts/{sourceId}, where {sourceId} comes from your Sources list.

  4. Send the token in the x-webhook-token header:

    curl -X POST "https://{customerPublicId}.lgnapi.com/v1/contacts/{sourceId}" \
      -H "x-webhook-token: $OSPRY_WEBHOOK_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{"contacts":[{"email":"jane@acme.com","externalId":"crm-123"}]}'
    

If your tool cannot set headers, add ?token=<your-webhook-token> to the URL instead. Use the header whenever you can: full URLs, query string included, end up in server logs, proxy logs and tool histories, which spreads the token to places it should not be.

A wrong token, an unknown source or an inactive source all return the same 401 unauthorized.

CRM connections

CRM connections authenticate differently from API keys.

CRM How it connects Direction
HighLevel OAuth2. Open Reach -> HighLevel, click Connect a sub-account, and approve the connection in HighLevel. Two-way: contacts come in from HighLevel, and enriched data is written back.
HubSpot CRM, HubSpot Marketing Paste a private-app or API token into the connection's Access token field. One-way: OSPRY pushes to HubSpot.
Salesforce Paste an API token into the connection's Access token field. One-way: OSPRY pushes to Salesforce.
  • HighLevel is the only CRM with OAuth and two-way sync today. You do not create an API key for it. Contacts from a connected sub-account are tied to your account through the connection itself. See Import, enrich, and sync contacts with HighLevel.
  • HubSpot and Salesforce use a pasted token and push one way. OSPRY does not read data back from them. Guided OAuth sign-in for these connections is planned.
  • OSPRY has no Close integration.

Tips & FAQs

  • One key per system. Give each integration its own key. You can then rotate or revoke one without breaking the others.
  • Keys and webhook secrets are different things. An API key (lsk_) authenticates your calls to OSPRY. A webhook signing secret (whsec_) lets you check calls from OSPRY. See Receiving OSPRY webhooks.
  • Rotate, then switch, then revoke. Rotate the key, deploy the new key within 24 hours, and revoke the old one once your system uses the new key.
  • A leaked key: revoke first. Revoking takes effect right away. Then create a replacement.
  • Members cannot manage keys. Only owners, admins and agency admins see Inbound Integrations.