Documentation
Developers
Public API

Public API

The Public API lets your own systems manage contacts and their segments. A change made through the API behaves exactly like one made in the app:

  • joining a segment enrolls the contact in running campaigns that have Auto-Enroll on;
  • leaving it stops runs in campaigns set to Stop the run;
  • every change appears in the execution logs.

Base URL: https://api.botphonic.ai/api. Every path below is relative to it, e.g. GET https://api.botphonic.ai/api/v1/segments.

Endpoints

MethodPathScopePurpose
GET/v1/segmentssegments:readList segments
GET/v1/segments/{id}segments:readGet one segment
POST/v1/segments/{id}/memberssegments:writeAdd or remove contacts (bulk)
POST/v1/segments/movesegments:writeMove contacts between segments (bulk)
GET/v1/contacts/lookupcontacts:readFind a contact and its segments
POST/v1/contactscontacts:writeCreate or update contacts (bulk)
PATCH/v1/contacts/{ref}contacts:writeUpdate one contact
DELETE/v1/contacts/{ref}contacts:writeDelete one contact
GET POST PATCH DELETE/v1/webhookswebhooks:manageManage webhook endpoints

Send JSON bodies with Content-Type: application/json.

Download the OpenAPI 3.1 specification to import into Postman or Insomnia, or to generate a client library for your language.


Authentication

Send an API key as a bearer token on every request:

Authorization: Bearer bp_live_xxxxxxxx_yyyyyyyy…

Each key belongs to one workspace, and every request only reaches that workspace's data. Each endpoint needs the scope listed with it below. Changes (anything except GET) also need an active plan or wallet credit on the account.

Identifying contacts

You never need Botphonic's internal ids. Each contact record identifies a person by any of:

FieldNotes
externalIdYour own id for the person (recommended). Unique within the workspace
emailEmail address
phoneE.164 format, e.g. +14155550101

A record can also carry firstName, lastName and tags. Records are matched in this order: externalId, then phone + email, then phone, then email.

An externalId only needs to be unique within one workspace. Other Botphonic customers can use the same ids without clashing. Two workspaces on your own account are also separate: the same externalId in each refers to two different contacts. To keep one person in sync across workspaces, send the update with each workspace's API key.

Bulk results

These three endpoints accept up to 1,000 contact records per call and return an outcome for each one:

MethodPath
POST/v1/segments/{id}/members
POST/v1/segments/move
POST/v1/contacts

A bad record never fails the rest of the batch: the request returns 200 and the record is reported as invalid. Example response from POST /v1/segments/{id}/members:

{
  "status": 200,
  "statusState": "success",
  "message": "Contacts added to segment",
  "data": {
    "summary": { "matched": 998, "created": 1, "invalid": 1 },
    "results": [
      { "index": 0, "status": "matched", "contactId": "6abb8f145d5c0515687d34be" },
      { "index": 1, "status": "created", "contactId": "6abb8f145d5c0515687d34bf" },
      { "index": 2, "status": "invalid", "error": "phone must be a valid E.164 number, e.g. +14155552671" }
    ]
  }
}
StatusMeaning
matchedAn existing contact was found and changed
createdA new contact was created (only where the endpoint allows it)
not_foundNo contact matched and none was created
invalidThe record failed validation. See error
ambiguousMore than one contact matched. Send externalId, or both phone and email

index is the record's position in the contacts array you sent.


Segments

List segments

GEThttps://api.botphonic.ai/api/v1/segmentsScope segments:read
QueryDefaultNotes
page1
perPage25Max 100
searchFilter by name
{
  "data": {
    "records": [
      {
        "id": "6abb8f14…",
        "name": "Trial users",
        "rule": { "allContacts": false, "tags": ["trial"] },
        "memberCount": 1842,
        "createdAt": "2026-09-01T10:00:00.000Z",
        "updatedAt": "2026-09-20T08:12:00.000Z"
      }
    ],
    "page": 1, "perPage": 25, "total": 7
  }
}

memberCount can lag by up to a minute after a large change.

Get a segment

GEThttps://api.botphonic.ai/api/v1/segments/{id}Scope segments:read

Add or remove contacts

POSThttps://api.botphonic.ai/api/v1/segments/{id}/membersScope segments:write
Body fieldRequiredNotes
actionYesadd or remove
contactsYes1–1,000 contact records
createMissingNoadd only. Create unmatched records that include phone, firstName and lastName
curl -X POST https://api.botphonic.ai/api/v1/segments/<segmentId>/members \
  -H "Authorization: Bearer $BOTPHONIC_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: signup-user_42" \
  -d '{
    "action": "add",
    "createMissing": true,
    "contacts": [
      { "externalId": "user_42", "email": "ann@example.com",
        "phone": "+14155550101", "firstName": "Ann", "lastName": "Lee" }
    ]
  }'

Removing a contact from a tag-based or all-contacts segment keeps it out even though its tags still match. Adding it back includes it again.

Move contacts between segments

POSThttps://api.botphonic.ai/api/v1/segments/moveScope segments:write

Removes the contacts from every from segment and adds them to every to segment as one change. A campaign that targets both sides sees no exit and no re-entry, so the contact's run isn't interrupted.

{
  "from": ["<trialSegmentId>"],
  "to": ["<paidSegmentId>"],
  "contacts": [{ "externalId": "user_42" }]
}

from and to each take 1–50 segment ids. Contacts are not created by this endpoint.


Contacts

Look up a contact

GEThttps://api.botphonic.ai/api/v1/contacts/lookup?externalId=user_42Scope contacts:read

Pass one of externalId, email or phone. Returns 404 if nothing matches, and 409 if more than one contact matches.

{
  "data": {
    "id": "6abb8f145d5c0515687d34be",
    "externalId": "user_42",
    "firstName": "Ann",
    "lastName": "Lee",
    "email": "ann@example.com",
    "phone": "+14155550101",
    "tags": ["trial"],
    "segments": [
      { "id": "6abb8f14…", "name": "Trial users", "via": "tag" },
      { "id": "6abb8f15…", "name": "Newsletter", "via": "static" }
    ],
    "createdAt": "…", "updatedAt": "…"
  }
}

via says why the contact is in the segment: static (added directly), tag (matches the segment's tags) or all (segment includes all contacts).

Create or update contacts

POSThttps://api.botphonic.ai/api/v1/contactsScope contacts:write
{ "contacts": [ { "externalId": "user_42", "firstName": "Ann", "tags": ["paid"] } ] }
  • Unmatched records are created. They need phone, firstName and lastName.
  • Matched records get the firstName, lastName and tags you send. tags replaces the contact's tags, which moves it into or out of tag-based segments.
  • externalId and email are only filled in when the contact doesn't have one yet. A matched contact with a different externalId is reported as invalid, never overwritten.

Update a contact

PATCHhttps://api.botphonic.ai/api/v1/contacts/{ref}Scope contacts:write

{ref} is a contact id or ext:<externalId> (e.g. ext:user_42). Send any of externalId, email, phone, firstName, lastName, tags. The response is the contact with its current segments.

Delete a contact

DELETEhttps://api.botphonic.ai/api/v1/contacts/{ref}Scope contacts:write

The contact leaves every segment. Campaigns set to Stop the run cancel its active runs.


Webhook endpoints

GEThttps://api.botphonic.ai/api/v1/webhooksScope webhooks:manage
POSThttps://api.botphonic.ai/api/v1/webhooksScope webhooks:manage
PATCHhttps://api.botphonic.ai/api/v1/webhooks/{id}Scope webhooks:manage
DELETEhttps://api.botphonic.ai/api/v1/webhooks/{id}Scope webhooks:manage

Manage the same endpoints as the Developers → Webhooks page. See Webhooks.


Limits and retries

LimitValue
Requests per key600 per minute
Bulk requests (/members, /move, POST /contacts)60 per minute
Records per bulk request1,000

Over the limit, the API returns 429 with a Retry-After header (seconds). Every response carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset.

Idempotency

Send Idempotency-Key: <unique string> (up to 128 characters) on writes. If the same key is used again within 24 hours, the first response is returned with Idempotent-Replayed: true, and nothing is applied twice. This makes it safe to retry after a timeout. A request that failed can be retried with the same key.

Errors

Errors use the same envelope, with statusState: "error" and a message.

StatusMeaning
401Missing, malformed, revoked or expired API key
402No active plan or wallet credit (changes only)
403The key is missing a required scope
404Segment or contact not found in this workspace
409Conflict, e.g. an ambiguous lookup, or the same Idempotency-Key still in progress
422Validation failed. message lists the problems
429Rate limit exceeded. Wait Retry-After seconds

Membership changes are applied as soon as the request returns. The workflow side effects (enrolling or stopping runs, sending webhooks) run in the background, usually within seconds.