# Project Blue API > Send iMessage and SMS, place FaceTime Audio calls, manage contacts, and run Workflows from your own application. REST over HTTPS with bearer token auth; an MCP server is also available. A browser SDK (@tryprojectblue/dialer) places and receives phone calls on your lines. # Project Blue API Send iMessage and SMS from your own application. Integrate messaging into your CRM, workflows, or custom tools with a single API call. The API is organised around REST. It accepts JSON request bodies, returns JSON responses, and uses standard HTTP verbs and status codes. Every request is authenticated with a bearer token. > **Reading this with an AI assistant?** > > Every section is also served as Markdown. [/llms.txt](https://api.tryprojectblue.com/llms.txt) indexes them, [/llms-full.txt](https://api.tryprojectblue.com/llms-full.txt) is the whole reference in one file, and each section has its own `/llms/
.md` — the **View as Markdown** link at the top of each section points at it. Point your agent at those rather than scraping the page. ### Base URL # Quickstart Four steps from an API key to a delivered message. Every call here is copy-paste ready. ## 1. Get a key, then check it Create a key in the Project Blue dashboard under **Settings → API Keys**. Keys start with `proj_` followed by 64 hex characters, and you may hold five active keys at a time. > **The full key is shown once** > > The value is returned only at creation. Every later view is masked to the first 12 and last 4 characters, so store it somewhere durable now. If you lose it, delete the key and make a new one. Start with `/get-lines`. It is the right first call because it reads rather than sends, and because its answer tells you which of the two setups you are in. | You got | It means | Do next | | --- | --- | --- | | A JSON array | Paid account with its own line | Note a lineId, skip to step 3 | | An object with `trial: true` | Trial account on the shared line | Do step 2 first | | `401` | The key never reached us, or was rejected | See below | The two `401` bodies mean different things. `Missing or invalid Authorization header` means the header was absent or lacked the `Bearer ` prefix — the request never carried a key. `Invalid API key` means the header was well-formed but the key is wrong, revoked, or from another account. ## 2. Get a number you can text On a paid account, skip this — any valid number works. On a trial, sends route through a shared Project Blue line and can only reach **verified** destinations. Verification is confirmed by an inbound text: the owner of that number must text the shared line from their own phone. Nothing in the API or the dashboard can confirm it on their behalf. > **Testing on your own? Verify yourself in a minute** > > Register your own mobile number in the webapp under **Settings**, text the shared line from that phone, then send to yourself in step 3. That is the whole loop, and it needs nobody else. Sending to an unverified destination returns `403` with `Trial accounts can only message numbers verified on the shared line.` See [Trial accounts](https://api.tryprojectblue.com/docs/trial-accounts) for what else is restricted. ## 3. Send the message Two fields is the whole request. If the recipient has iMessage it arrives as one; otherwise it falls back to SMS automatically. A success returns `status: "done"` — but no message id, which is why there is a step 4. ## 4. Confirm it landed The send response tells you the message was accepted, not that it was delivered. Read it back from [list messages](https://api.tryprojectblue.com/docs/list-messages) filtered to the number you texted, and check `data[0].status`. The same row carries the `message_handle` you need for [get a message](https://api.tryprojectblue.com/docs/get-message). In production, register a [webhook](https://api.tryprojectblue.com/docs/webhooks) instead of polling. ### Before you loop 1. **Re-running the same send is collapsed, not repeated.** Identical text to the same number within the hour returns `200` with `deduped: true` and sends nothing. Change the text or pass a distinct `idempotencyKey`. This is the most common reason a first integration looks like it worked but nothing arrived. 2. [60 requests per minute](https://api.tryprojectblue.com/docs/rate-limits) per key, then `429` with `retryAfterSeconds`. 3. Numbers are normalized to E.164. Most formats are accepted on the way in; everything comes back as `+15551234567`. 4. Trial sends are real messages on a line shared with other accounts. Do not load-test them — unverified probing burns iMessage reputation for everyone on that line. **1 · Check your key — cURL** Safe to run — reads your lines, sends nothing. ```bash export PB_API_KEY=proj_... curl -s https://api.tryprojectblue.com/get-lines \ -H "Authorization: Bearer $PB_API_KEY" ``` **What comes back — Paid** An array. Note a lineId and skip to step 3. ```json [ { "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "devicePhoneNumber": "+15559876543", "customName": "Main Line" }, { "lineId": "9c2e4a1b-d3f8-4e1c-a2b4-c5d6e7f8a9b0", "devicePhoneNumber": "+15557654321", "customName": "Secondary Line" } ] ``` **What comes back — Trial** An envelope, not an array. Do step 2 first. ```json { "lines": [], "trial": true, "message": "This is a trial account. Sends route through a shared Project Blue line to your verified destinations. Your real line info will appear here after you upgrade." } ``` **What comes back — 401 — header** ```json { "error": "Missing or invalid Authorization header" } ``` **What comes back — 401 — key** ```json { "error": "Invalid API key" } ``` **3 · Send — cURL** ```bash curl -X POST https://api.tryprojectblue.com/send-api-message \ -H "Authorization: Bearer $PB_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "message": "Hello from the Project Blue API", "phone": "+15551234567" }' ``` **3 · Send — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/send-api-message", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "message": "Hello from the Project Blue API", "phone": "+15551234567" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **3 · Send — cURL · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/send-api-message", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"message": "Hello from the Project Blue API", "phone": "+15551234567"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **3 · Send — Node** ```javascript const res = await fetch( "https://api.tryprojectblue.com/send-api-message", { method: "POST", headers: { Authorization: `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ message: "Hello from the Project Blue API", phone: "+15551234567", }), }, ); const body = await res.json(); if (!res.ok) throw new Error(body.error); console.log(body.status); // "done" ``` **3 · Send — Python** ``` import os, requests res = requests.post( "https://api.tryprojectblue.com/send-api-message", headers={"Authorization": f"Bearer {os.environ['PB_API_KEY']}"}, json={ "message": "Hello from the Project Blue API", "phone": "+15551234567", }, timeout=30, ) res.raise_for_status() print(res.json()["status"]) # "done" ``` **4 · Confirm — cURL** ```bash curl -sG https://api.tryprojectblue.com/get-messages-api \ -H "Authorization: Bearer $PB_API_KEY" \ --data-urlencode "direction=outbound" \ --data-urlencode "to_number=+15551234567" \ --data-urlencode "limit=1" ``` **4 · Confirm — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const url = new URL("https://api.tryprojectblue.com/get-messages-api"); url.searchParams.append("direction", "outbound"); url.searchParams.append("to_number", "+15551234567"); url.searchParams.append("limit", "1"); const response = await fetch(url, { method: "GET", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}` } }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **4 · Confirm — cURL · Python** ```python import os import requests response = requests.request( "GET", "https://api.tryprojectblue.com/get-messages-api", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"] }, params=[("direction", "outbound"), ("to_number", "+15551234567"), ("limit", "1")], timeout=30, ) response.raise_for_status() print(response.json()) ``` **4 · Confirm — 200 OK** ```json { "status": "OK", "data": [ { "message_handle": "pbm_outk6dawyUgbl-EjXCZk-g5mZnmwmSbilbaX", "content": "Hello from the Project Blue API", "to_number": "+15551234567", "service": "iMessage", "direction": "outbound", "status": "delivered", "sent_at": "2026-08-17T18:04:12.000Z" } ], "pagination": { "limit": 1, "offset": 0, "total": 1 } } ``` # Authentication All API requests require a bearer token in the `Authorization` header. You can generate API keys from within your Project Blue dashboard under **Settings → API Keys**. ![API Keys settings in the Project Blue dashboard](https://api.tryprojectblue.com/pb-app/pb_api.png) > **Keep your API keys secure** > > Never expose your API key in client-side code or public repositories. Always make API calls from your server. **Request — HTTP header** ```http Authorization: Bearer YOUR_API_KEY ``` **Example — cURL** ```bash curl -X POST https://api.tryprojectblue.com/send-api-message \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "message": "Hey! Just following up on our conversation.", "phone": "+15551234567" }' ``` **Example — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/send-api-message", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "message": "Hey! Just following up on our conversation.", "phone": "+15551234567" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Example — cURL · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/send-api-message", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"message": "Hey! Just following up on our conversation.", "phone": "+15551234567"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` # Trial accounts Trial accounts (accounts still on a trial, before conversion to a paid line) get real API access — not a simulator. Sends are real messages. The difference is that a trial account sends through a shared Project Blue line, and it can only reach destinations that have been verified. ## Verifying a destination 1. Register the destination in the Project Blue webapp under **Settings**. This creates a pending verification pinned to your shared line. 2. **The owner of that destination texts the shared line from their own phone.** That inbound text is what confirms the verification. There is no way to confirm it from the API or the dashboard. 3. The destination shows as verified in the webapp, and API sends to it start succeeding. Destination registration is webapp-only today — there is no API-key equivalent for registering a number or polling verification status yet. Sending or probing an unverified destination returns 403 with `Trial accounts can only message numbers verified on the shared line.` ## Endpoint availability | Endpoint | Trial | Notes | | --- | --- | --- | | `/send-api-message` | Restricted | Verified destinations only. lineId is rejected (see below). | | `/api-check-imessage-availability` | Restricted | Verified destinations only. | | `/get-lines` | Restricted | Returns a trial envelope (empty lines list) instead of owned lines. | | `/request-line` | Available | | | `/get-messages-api` | Available | Reads your own messages only. | | `/get-message-api/:message_handle` | Available | Reads a single message you own. | | `/create-external-contact` | Available | | | `/get-external-contacts` | Available | | | `/update-external-contact` | Available | | | `/get-call-logs-api` | Available | | | `/get-flows` | Available | List published Workflows. Each id is an opaque UUID string. | | `/cancel-flow-runs` | Available | | | `Webhooks` | Available | Inbound/outbound webhook delivery for your account. | | `/get-effects` | Unavailable | This endpoint is not available on trial accounts. | | `/send-reaction` | Restricted | Verified destinations only. iMessage tapbacks. | | `/send-group-message` | Unavailable | Trial accounts cannot create group chats. | | `/enroll-flow` | Unavailable | Flow enrollment is not available on trial accounts. | | `/start-facetime-call-api` | Unavailable | FaceTime calling is not available on trial accounts. | | `/set-contact-card` | Unavailable | Trial sends use a shared Project Blue line whose name and photo cannot be changed. | | `/get-contact-card` | Unavailable | Same gate as /set-contact-card. | | `/share-contact-card` | Unavailable | Same gate as /set-contact-card. | | `/get-facetime-call-status-api` | Available | No dedicated trial gate; only useful if you already have a call_uuid. | | `/end-facetime-call-api` | Available | No dedicated trial gate; only useful if you already have a call_uuid. | > **lineId is not accepted on trial accounts** > > Trial sends route through the shared line, so the line is not selectable. Supplying `lineId` on `/send-api-message` returns 400 — see the rail. ## GET /get-lines on a trial account Trial accounts do not own a device line. `/get-lines` returns a trial envelope instead of an array of lines. **Response — 200 — trial /get-lines** ```json { "lines": [], "trial": true, "message": "This is a trial account. Sends route through a shared Project Blue line to your verified destinations. Your real line info will appear here after you upgrade." } ``` **Response — 400 — lineId rejected** ```json { "error": "lineId is not accepted on trial accounts. Sends route through the shared line automatically." } ``` # Webhooks Webhooks notify you in real time when messages are sent or received and when an inbound FaceTime Audio call rings, is answered, or ends. Configure webhooks from within the Project Blue dashboard alongside your API keys. ## Configuration In the Project Blue app, you can: - Paste the webhook URL you want to receive events at - Choose which events the webhook receives: inbound messages, outbound messages, inbound FaceTime calls - Send test payloads to verify your endpoint is working ![Sample message and FaceTime call payloads on the API Webhooks tab](https://api.tryprojectblue.com/pb-app/pb_webhook.png) ![Add webhook form with inbound messages, outbound messages, and inbound FaceTime calls](https://api.tryprojectblue.com/pb-app/pb_webhook_types.png) ## Delivery Your endpoint should answer `2xx`. Anything else — including a network error or a timeout — counts as a failure. **There are no retries.** Each event is delivered exactly once; a failed delivery is not queued or replayed, so a webhook is not a durable log. Reconcile with [`/get-messages-api`](https://api.tryprojectblue.com/docs/list-messages) if you need guaranteed coverage. After **20 consecutive failures** the webhook is automatically disabled. The counter resets on the first success. Today that happens silently — there is no email and no dashboard banner, so check the Webhooks tab if events stop arriving. ## Webhook payload Message payloads include an additive `event` key, `message.inbound` or `message.outbound`, plus `isGroup`, `groupId`, `sender`, and `participants`. The `direction` field still indicates whether the message was inbound or outbound. For group messages `destination` is the group's chat id (`chat…`), not an E.164 number. Call payloads are documented at [Inbound FaceTime calls](https://api.tryprojectblue.com/docs/facetime-inbound). - `event` ("message.inbound" | "message.outbound", required) — Additive key on message webhooks. Call events use facetime.inbound.ringing, facetime.inbound.answered, or facetime.inbound.ended and are documented under Inbound FaceTime calls. - `message` (string, required) — The text content of the message. - `destination` (string, required) — The phone number the message was sent to, in E.164 format. For group messages this is the group's chat id (chat…), not an E.164 number. - `receivedAt` (string, required) — ISO 8601 timestamp of when the message was received. - `direction` (string, required) — Either "inbound" or "outbound", based on message direction. - `messageId` (number, required) — Unique numeric identifier for the message. - `guid` (string, required) — Globally unique message identifier. - `linePhoneNumber` (string, required) — The Project Blue line phone number associated with this message. - `isGroup` (boolean, required) — true when the message is in a group chat, false on 1:1. HubSpot automation webhooks include this field only among the group fields below. - `groupId` (string | null, required) — The pbg_ id returned by POST /send-group-message, or null on 1:1 messages. Settings > Webhooks and Zapier payloads include this field; HubSpot automation webhooks do not. - `sender` (string | null, required) — Inbound sender address. Null on outbound. Settings > Webhooks and Zapier payloads include this field; HubSpot automation webhooks do not. - `participants` (string[] | null, required) — Participant addresses on group messages, or null on 1:1. Settings > Webhooks and Zapier payloads include this field; HubSpot automation webhooks do not. > **HubSpot accounts receive a wider payload** > > On accounts whose webhooks are configured through the HubSpot variant of the Webhooks tab, the original message fields are still present, plus `contactPhoneNumber`, `dateReceived` (a legacy alias for `receivedAt`), `hubspotContactId` (number), and `hubspotContactIdText` (the same id as a string). HubSpot automation webhooks gain `isGroup` only, not `groupId`, `sender` or `participants`. Those webhooks have no inbound/outbound toggles and are not covered by the auto-disable behaviour described above. **Payload — Inbound** ```json { "event": "message.inbound", "message": "Yes, I'm interested! When can we schedule?", "destination": "+15551234567", "receivedAt": "2026-03-04T18:30:00.000Z", "direction": "inbound", "messageId": 456, "guid": "sample-guid-1234", "linePhoneNumber": "+15559876543", "isGroup": false, "groupId": null, "sender": "+15551234567", "participants": null } ``` **Payload — Outbound** ```json { "event": "message.outbound", "message": "Great! Let's book you in for Thursday at 2pm.", "destination": "+15551234567", "receivedAt": "2026-03-04T18:31:00.000Z", "direction": "outbound", "messageId": 789, "guid": "sample-guid-5678", "linePhoneNumber": "+15559876543", "isGroup": false, "groupId": null, "sender": null, "participants": null } ``` **Payload — Group** destination is the group's chat id (chat…), not an E.164 number. ```json { "event": "message.inbound", "message": "I'll be there at 2.", "destination": "chat226184318376216326", "receivedAt": "2026-03-04T18:30:00.000Z", "direction": "inbound", "messageId": 456, "guid": "sample-guid-1234", "linePhoneNumber": "+15559876543", "isGroup": true, "groupId": "pbg_...", "sender": "+15551230000", "participants": ["+15551230000", "+15551230001"] } ``` **Payload — FaceTime ringing** Answered and ended events are in Inbound FaceTime calls. ```json { "event": "facetime.inbound.ringing", "call_uuid": "ftc_8a2b1c3d4e5f6g7h", "direction": "inbound", "from": "+15551234567", "pb_line_id": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "linePhoneNumber": "+15559876543", "ringingAt": "2026-09-15T18:04:02.000Z", "receivedAt": "2026-09-15T18:04:02.310Z" } ``` # CRM integration The send endpoint works hand-in-hand with your CRM. If you have **HighLevel** or **HubSpot** connected, outbound messages sent through the API appear inside your CRM — just like messages sent from the Project Blue app. ## Auto-create contacts By default, `shouldAutoCreateContact` is `true`. This means if you send an outbound message and the recipient does not already exist as a contact in your CRM, we will automatically create the contact for you along with the message. Set `shouldAutoCreateContact` to `false` if you only want messages logged for contacts that already exist in your CRM. > **This field is only relevant if you have a supported CRM connected** > > If no CRM is connected, `shouldAutoCreateContact` has no effect. Messages are still sent normally regardless of this setting. ## HighLevel Outbound messages are synced directly into **Conversations**. If the contact doesn't exist and auto-create is enabled, we create the contact and the message appears in their conversation thread. ## HubSpot Outbound messages are logged as an **activity** on the contact record. If you have a HubSpot **Inbox** enabled, the message is also delivered there for your team to see and reply from. If the contact doesn't exist and auto-create is enabled, we create the contact in HubSpot first, then log the activity. **Request — Existing contacts only** The message is logged only if the contact already exists. ```bash curl -X POST https://api.tryprojectblue.com/send-api-message \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "message": "Hey! Following up on our call earlier.", "phone": "+15551234567", "shouldAutoCreateContact": false }' ``` **Request — Existing contacts only · JavaScript** The message is logged only if the contact already exists. ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/send-api-message", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "message": "Hey! Following up on our call earlier.", "phone": "+15551234567", "shouldAutoCreateContact": false }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — Existing contacts only · Python** The message is logged only if the contact already exists. ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/send-api-message", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"message": "Hey! Following up on our call earlier.", "phone": "+15551234567", "shouldAutoCreateContact": False}, timeout=30, ) response.raise_for_status() print(response.json()) ``` # Supported media Use the `mediaAttachmentUrl` field to send rich media with your messages. The following formats are supported. ## Images `JPEG / JPG`, `PNG`, `GIF`, `WebP` ## Videos `MP4`, `MOV`, `AVI`, `MKV`, `FLV`, `WebM` ## Contact cards `VCF / vCard` # Voice memos & audio Use `audioAttachmentUrl` to send audio files as voice memos. The following formats are supported. `M4A`, `MP3`, `WAV`, `OGG`, `WebM`, `CAF` > **AI voice memos** > > Set `enableAiVoiceMemo` to `true` and include a `message` to generate a natural-sounding voice memo via text-to-speech. No audio file needed — we generate it for you. # Rate limits Every API-key endpoint allows **60 requests per minute**, counted per API key in a rolling 60-second window. Each response carries `RateLimit-Limit`, `RateLimit-Remaining`, and `RateLimit-Reset`. A rejected request also carries `Retry-After`, and the body repeats the wait as `retryAfterSeconds`. > **The limit is counted before your key is checked** > > Requests are bucketed by the token in the `Authorization` header, and that happens before the key is validated. Requests made with a revoked or mistyped key still consume that token's budget, and requests with no `Authorization` header at all share a single per-IP bucket. > **Two different limits return 429** > > This per-minute limit is not the only one. [FaceTime](https://api.tryprojectblue.com/docs/facetime-end) separately caps dialling at 40 unique destinations per calendar day and returns 429 with `error_code: FACETIME_DAILY_LIMIT_REACHED`. Branch on `error_code` rather than on the status alone: waiting `retryAfterSeconds` will never clear the daily cap. **Response — 429** ```json { "error": "Rate limit exceeded", "message": "Too many requests. Please wait before sending more messages.", "retryAfterSeconds": 60 } ``` # Error handling The API uses standard HTTP status codes. All error responses include a JSON body with an `error` field describing what went wrong. ### Status codes - **200** — Message sent successfully - **400** — Invalid request body or missing required fields - **401** — Missing or invalid API key - **403** — Forbidden — e.g. endpoint unavailable on trial accounts (see Trial accounts), unverified trial destination, or opted-out contact - **409** — Conflict — a group already exists on another line, a Workflow run is already active for this contact, or a trial account has no shared line provisioned - **429** — Rate limit exceeded (60 requests/minute per key), or the FaceTime daily dial cap - **500** — Internal server error Two error bodies are worth special-casing. `Pagination depth too deep` means `offset + limit` exceeded 2000 on [list messages](https://api.tryprojectblue.com/docs/list-messages) or [call logs](https://api.tryprojectblue.com/docs/call-logs) — narrow the query by date or line rather than paging deeper. `This trial account is not provisioned on a shared line` is a 409 that only trial accounts see; it means the destination is verified but the account has no shared line yet. **Response — 401 Unauthorized** ```json { "error": "Missing or invalid Authorization header" } ``` # Send a message Send a message to a phone number via iMessage or SMS. If the recipient has iMessage, the message is delivered as an iMessage (blue bubble). Otherwise, it falls back to SMS automatically. `POST /send-api-message` > **Using a trial account?** > > Send to a verified destination from the shared line. [Set up your trial](https://api.tryprojectblue.com/docs/trial-accounts) before making your first request. ### Request body - `message` (string) — The text content of the message. Required unless mediaAttachmentUrl or audioAttachmentUrl is supplied. - `phone` (string, required) — Recipient phone number. Accepts many formats — we normalize to E.164 (e.g. +15551234567). - `lineId` (string (UUID v4)) — Optional sender line override. Use the lineId value returned from GET /get-lines. When omitted, messages are load balanced across available lines. Rejected on trial accounts — see Trial Accounts. - `mediaAttachmentUrl` (string) — URL to an image, video, or contact card attachment. - `audioAttachmentUrl` (string) — URL to an audio file sent as a voice memo. - `enableAiVoiceMemo` (boolean) — When true, generates an AI voice memo from the message text using text-to-speech. - `shouldAutoCreateContact` (boolean) — Defaults to true. When enabled and a supported CRM is connected (HighLevel or HubSpot), automatically creates the contact in your CRM if they don't already exist. - `firstName` (string) — First name to persist on the auto-created Project Blue contact for this recipient. Applies to accounts without a connected CRM (external/API source). - `lastName` (string) — Last name to persist on the auto-created Project Blue contact for this recipient. Applies to accounts without a connected CRM (external/API source). - `email` (string) — Email address to persist on the auto-created Project Blue contact for this recipient. Applies to accounts without a connected CRM (external/API source). - `customFields` (object) — Arbitrary JSON metadata (e.g. order IDs, links) persisted on the auto-created contact and shown in the contact details panel in the Project Blue app. Plain object only; max 10,000 characters when JSON-serialized. - `idempotencyKey` (string) — 1 to 200 characters. Values outside those bounds are silently ignored, not rejected. When omitted, the key defaults to your user id plus the destination plus the message text, so an identical retry within the hour is collapsed rather than sent twice. - `effect` (string) — iMessage-only send effect applied to this one message. Bubble: slam, loud, gentle, invisible-ink. Screen: confetti, balloons, hearts, lasers, fireworks, echo, spotlight, shooting-star, celebration. Invalid on SMS (400). Use sparingly. The `phone` parameter is flexible — we accept formats like `(555) 123-4567`, `555.123.4567`, `+15551234567`, and more. All numbers are normalized to E.164 format before sending. When `lineId` is provided, we route through that line. If it is omitted, message sends continue to use default load balancing across your available lines. > **iMessage-only send effects** > > Optional `effect` applies to this one message and only works on iMessage. SMS destinations return `400`. Bubble effects animate the bubble: `slam`, `loud`, `gentle`, `invisible-ink`. Screen effects take over the recipient's screen: `confetti`, `balloons`, `hearts`, `lasers`, `fireworks`, `echo`, `spotlight`, `shooting-star`, `celebration`. Use sparingly. `GET /get-effects` returns the same list. > **Identical sends are collapsed for an hour** > > With no `idempotencyKey`, the key defaults to your user id plus the destination plus the message text. Sending the same text to the same number twice within the hour returns `200` with `deduped: true` and **does not send a second message**. This is the usual reason a first integration looks like it succeeded but nothing arrived on the retry — change the text, or pass a distinct `idempotencyKey`, when a repeat is intentional. A replay returns `status: "done"` when the original send finished, or `status: "processing"` with `messageType` and `devicePhoneNumber` still `null` while it is in flight. Both carry `deduped: true`; a first-time send never does. **Request — Basic** ```bash curl -X POST https://api.tryprojectblue.com/send-api-message \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "message": "Hey! Just following up on our conversation.", "phone": "+15551234567" }' ``` **Request — Basic · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/send-api-message", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "message": "Hey! Just following up on our conversation.", "phone": "+15551234567" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — Basic · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/send-api-message", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"message": "Hey! Just following up on our conversation.", "phone": "+15551234567"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Request — Media** Attach an image, video, or contact card by URL. ```bash curl -X POST https://api.tryprojectblue.com/send-api-message \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "message": "Check out this property!", "phone": "+15551234567", "mediaAttachmentUrl": "https://example.com/property-photo.jpg" }' ``` **Request — Media · JavaScript** Attach an image, video, or contact card by URL. ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/send-api-message", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "message": "Check out this property!", "phone": "+15551234567", "mediaAttachmentUrl": "https://example.com/property-photo.jpg" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — Media · Python** Attach an image, video, or contact card by URL. ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/send-api-message", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"message": "Check out this property!", "phone": "+15551234567", "mediaAttachmentUrl": "https://example.com/property-photo.jpg"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Request — AI voice memo** Generates speech from the message text — no audio file needed. ```bash curl -X POST https://api.tryprojectblue.com/send-api-message \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "message": "Hey, wanted to quickly touch base about your appointment tomorrow.", "phone": "+15551234567", "enableAiVoiceMemo": true }' ``` **Request — AI voice memo · JavaScript** Generates speech from the message text — no audio file needed. ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/send-api-message", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "message": "Hey, wanted to quickly touch base about your appointment tomorrow.", "phone": "+15551234567", "enableAiVoiceMemo": true }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — AI voice memo · Python** Generates speech from the message text — no audio file needed. ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/send-api-message", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"message": "Hey, wanted to quickly touch base about your appointment tomorrow.", "phone": "+15551234567", "enableAiVoiceMemo": True}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Request — Line override** Force a specific sending line instead of load balancing. ```bash curl -X POST https://api.tryprojectblue.com/send-api-message \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "message": "Hi from a specific line.", "phone": "+15551234567", "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5" }' ``` **Request — Line override · JavaScript** Force a specific sending line instead of load balancing. ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/send-api-message", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "message": "Hi from a specific line.", "phone": "+15551234567", "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — Line override · Python** Force a specific sending line instead of load balancing. ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/send-api-message", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"message": "Hi from a specific line.", "phone": "+15551234567", "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Request — Confetti** iMessage-only screen effect. SMS destinations return 400. ```bash curl -X POST https://api.tryprojectblue.com/send-api-message \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "message": "You closed it!", "phone": "+15551234567", "effect": "confetti" }' ``` **Request — Confetti · JavaScript** iMessage-only screen effect. SMS destinations return 400. ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/send-api-message", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "message": "You closed it!", "phone": "+15551234567", "effect": "confetti" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — Confetti · Python** iMessage-only screen effect. SMS destinations return 400. ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/send-api-message", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"message": "You closed it!", "phone": "+15551234567", "effect": "confetti"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200 OK** ```json { "success": true, "status": "done", "message": "Message added to queue", "messageType": "iMessage", "phone": "+15551234567", "devicePhoneNumber": "+15559876543", "mediaAttachmentUrl": null, "audioAttachmentUrl": null } ``` **Response — 200 — replayed** A retry collapsed onto an earlier send. Nothing was sent again. ```json { "success": true, "status": "done", "message": "Message added to queue", "messageType": "iMessage", "phone": "+15551234567", "devicePhoneNumber": "+15559876543", "mediaAttachmentUrl": null, "audioAttachmentUrl": null, "deduped": true } ``` **Response — 200 — in flight** The original send is still processing, so the channel is not resolved yet. ```json { "success": true, "status": "processing", "message": "Message added to queue", "phone": "+15551234567", "messageType": null, "devicePhoneNumber": null, "deduped": true } ``` **Response — 400 — invalid line** ```json { "error": "Invalid lineId. Expected a UUID v4 token returned from GET /get-lines." } ``` # List messages Returns a paginated list of the authenticated user's messages — outbound and inbound merged into a single feed. Each message includes a durable `message_handle` that can be passed to `/get-message-api/:message_handle` for the full record. `GET /get-messages-api` ### Query parameters - `limit` (integer (1–100)) — Maximum number of messages to return. Defaults to 100. - `offset` (integer (≥ 0)) — Pagination offset. Defaults to 0. offset + limit must be ≤ 2000; deeper pages return 400 regardless of limit. - `order_by` ("createdAt" | "sentAt") — Sort field. Defaults to createdAt. - `order_direction` ("asc" | "desc") — Sort direction. Defaults to desc (newest first). - `service` ("iMessage" | "SMS" | "RCS") — Filter by delivery service. Note: RCS is inbound-only — combining service=RCS with direction=outbound returns zero results. - `direction` ("inbound" | "outbound") — Filter to inbound or outbound only. Omit for both. - `pb_line_id` (string) — Encoded Project Blue line id (from GET /get-lines). The only supported way to filter by one of your own PB lines — do not use from_number/to_number for that. - `from_number` (string (E.164)) — External sender. Inbound-only filter. Combining with direction=outbound returns 400. - `to_number` (string (E.164)) — External recipient. Outbound-only filter. Combining with direction=inbound returns 400. - `created_at_gte` (string (ISO-8601)) — Lower bound on created_at. - `created_at_lte` (string (ISO-8601)) — Upper bound on created_at. - `sent_at_gte` (string (ISO-8601)) — Lower bound on sent_at. - `sent_at_lte` (string (ISO-8601)) — Upper bound on sent_at. > **Group messages and from_number / to_number** > > On outbound group messages, `to_number` is the group's chat identifier (`chat…`), not an E.164 number. On inbound group messages, `from_number` is the individual participant who replied. The `to_number` and `from_number` filters are therefore not a way to fetch a group thread.There is currently no supported filter for reading one group thread from `/get-messages-api`. The `pbg_` groupId is not accepted as a filter, and the chat identifier is not exposed as a queryable field on this API. > **About message_handle** > > The `message_handle` is an opaque, user-scoped identifier. Don't try to parse or decode it — just hand it back to `/get-message-api` to look up that specific message. **Request — cURL** ```bash curl -G https://api.tryprojectblue.com/get-messages-api \ -H "Authorization: Bearer YOUR_API_KEY" \ --data-urlencode "limit=5" \ --data-urlencode "direction=outbound" \ --data-urlencode "service=SMS" ``` **Request — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const url = new URL("https://api.tryprojectblue.com/get-messages-api"); url.searchParams.append("limit", "5"); url.searchParams.append("direction", "outbound"); url.searchParams.append("service", "SMS"); const response = await fetch(url, { method: "GET", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}` } }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — cURL · Python** ```python import os import requests response = requests.request( "GET", "https://api.tryprojectblue.com/get-messages-api", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"] }, params=[("limit", "5"), ("direction", "outbound"), ("service", "SMS")], timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200 OK** ```json { "status": "OK", "data": [ { "message_handle": "pbm_outk6dawyUgbl-EjXCZk-g5mZnmwmSbilbaX-fvceChASMVXv1v26ONS0XENe2ggdJ82j9TMpw", "content": "Hello this is a message from desktop Claude!", "from_number": "+14804328406", "to_number": "+14808405291", "line_id": "7fd53c9a-5e6f-40e7-48c2-57663bad6c9c", "service": "SMS", "direction": "outbound", "status": "delivered", "created_at": "2026-04-19T07:30:14.525Z", "sent_at": "2026-04-19T16:00:31.091Z", "media_attachment_url": null, "voice_attachment_url": null } ], "pagination": { "limit": 100, "offset": 0, "total": 427 } } ``` **Response — 400 — filter** ```json { "error": "to_number only applies to outbound messages. Use pb_line_id to filter inbound messages by your own line." } ``` **Response — 400 — depth** offset + limit may not exceed 2000. ```json { "error": "Pagination depth too deep. offset+limit must be <= 2000" } ``` # Get a message Fetch a single message by its opaque `message_handle` (as returned from `/get-messages-api`). Handles are scoped to the authenticated user — a handle from another user's account returns `404`. `GET /get-message-api/:message_handle` ### Path parameters - `message_handle` (string, required) — Opaque handle starting with pbm_, returned by /get-messages-api. **Request — cURL** ```bash curl https://api.tryprojectblue.com/get-message-api/pbm_outk6dawyUgbl-EjXCZk-g5mZnmwmSbilbaX \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Request — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/get-message-api/pbm_outk6dawyUgbl-EjXCZk-g5mZnmwmSbilbaX", { method: "GET", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}` } }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — cURL · Python** ```python import os import requests response = requests.request( "GET", "https://api.tryprojectblue.com/get-message-api/pbm_outk6dawyUgbl-EjXCZk-g5mZnmwmSbilbaX", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"] }, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200 OK** ```json { "status": "OK", "data": { "message_handle": "pbm_outk6dawyUgbl-EjXCZk-g5mZnmwmSbilbaX", "content": "Hello this is a message from desktop Claude!", "from_number": "+14804328406", "to_number": "+14808405291", "line_id": "7fd53c9a-5e6f-40e7-48c2-57663bad6c9c", "service": "SMS", "direction": "outbound", "status": "delivered", "created_at": "2026-04-19T07:30:14.525Z", "sent_at": "2026-04-19T16:00:31.091Z", "media_attachment_url": null, "voice_attachment_url": null } } ``` **Response — 404** ```json { "error": "Message not found" } ``` **Response — 400** ```json { "error": "Invalid or missing message_handle" } ``` # Send a group message Send an iMessage or SMS to a group of 2 to 32 recipients. There is no create step — pass `numbers` every time. The same participant set resolves to the same thread. `POST /send-group-message` > **All or nothing iMessage** > > A group is delivered as iMessage only when every participant is iMessage reachable. One participant on Android drops the entire thread to SMS. > **Queued — service is always null here** > > `status` is always `"queued"` and `service` is always `null` on this endpoint. The send is never synchronous — whether the thread lands as iMessage or SMS is not known until the cron runs the all-participants availability probe. Read the resolved service from `/get-messages-api`. > **No CRM sync** > > Group sends are not mirrored into HighLevel, HubSpot, or Close, unlike single recipient sends via `/send-api-message`. ### Request body - `numbers` (string[], required) — Recipient phone numbers, 2 to 32 entries. Flexible formats accepted; normalized to E.164. Deduped after normalization. Passing the same set of participants again reuses the existing group thread. - `message` (string) — The text content of the message. Required unless an attachment is supplied. - `mediaAttachmentUrl` (string) — URL to an image, video, or contact card attachment. Mutually exclusive with audioAttachmentUrl. - `audioAttachmentUrl` (string) — URL to an audio file sent as a voice memo. Mutually exclusive with mediaAttachmentUrl. - `enableAiVoiceMemo` (boolean) — Generates a voice memo from message. - `groupName` (string) — Honored only when the group is created. Ignored on reuse. - `lineId` (string (UUID v4)) — From GET /get-lines. On reuse it must match the line the group already lives on. Rejected on trial accounts — see Trial Accounts. Group send itself is unavailable on trial. - `idempotencyKey` (string) — 1 to 200 characters. Values outside those bounds are silently ignored, not rejected. `groupStatus` is `"creating"` until the chat exists on the sending line, then `"active"`. `created` is `true` only when this call created the group. `groupId` is opaque and stable — do not parse it. On a replayed or deduplicated request, `groupId` and `devicePhoneNumber` can be `null`, because the group did not exist yet when the claim was taken. Group send is unavailable on trial accounts — see [Trial accounts](https://api.tryprojectblue.com/docs/trial-accounts). ### Status codes - **200** — Message queued successfully - **400** — Invalid request — missing message/attachment, both attachments, recipient count, email/chat handles, phone format, or lineId - **401** — Missing or invalid Authorization header / Invalid API key - **403** — Unavailable on trial (see Trial accounts) — e.g. Trial accounts cannot create group chats. Also: One or more recipients are blocked. - **409** — This group already exists on a different line. - **429** — Rate limit exceeded - **500** — Internal server error **Request — New group** groupName is honoured only when the group is created. ```bash curl -X POST https://api.tryprojectblue.com/send-group-message \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "numbers": ["+16025551234", "+14808405291"], "message": "Hey both, following up on the walkthrough.", "groupName": "Elm St walkthrough" }' ``` **Request — New group · JavaScript** groupName is honoured only when the group is created. ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/send-group-message", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "numbers": [ "+16025551234", "+14808405291" ], "message": "Hey both, following up on the walkthrough.", "groupName": "Elm St walkthrough" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — New group · Python** groupName is honoured only when the group is created. ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/send-group-message", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"numbers": ["+16025551234", "+14808405291"], "message": "Hey both, following up on the walkthrough.", "groupName": "Elm St walkthrough"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Request — Same group again** Same numbers resolve to the same thread — no groupId needed. ```bash curl -X POST https://api.tryprojectblue.com/send-group-message \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "numbers": ["+16025551234", "+14808405291"], "message": "Confirming 2pm Thursday." }' ``` **Request — Same group again · JavaScript** Same numbers resolve to the same thread — no groupId needed. ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/send-group-message", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "numbers": [ "+16025551234", "+14808405291" ], "message": "Confirming 2pm Thursday." }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — Same group again · Python** Same numbers resolve to the same thread — no groupId needed. ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/send-group-message", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"numbers": ["+16025551234", "+14808405291"], "message": "Confirming 2pm Thursday."}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200 OK** ```json { "success": true, "status": "queued", "groupId": "pbg_...", "created": true, "groupStatus": "creating", "service": null, "recipients": ["+16025551234", "+14808405291"], "devicePhoneNumber": "+15559876543", "mediaAttachmentUrl": null, "audioAttachmentUrl": null } ``` **Response — 409** ```json { "error": "This group already exists on a different line.", "devicePhoneNumber": "+15559876543" } ``` **Response — 403** ```json { "error": "Trial accounts cannot create group chats." } ``` **Response — 400** ```json { "error": "numbers must be an array of 2 to 32 phone number strings." } ``` # Typing indicators Show the iMessage typing indicator (the three dots) to a recipient. Authenticate with a Bearer API key, same as every other endpoint. `POST /send-typing-indicator` > **iMessage only, existing conversation required** > > Typing indicators are iMessage-only — SMS recipients never see them. The number must already have a conversation on the sending line; there is no indicator without a prior thread. ### Request body - `phoneNumber` (string (E.164), required) — Recipient phone number in E.164 (e.g. +15551234567). Must already have an existing conversation on the sending line. - `lineId` (string (UUID v4)) — Optional sender line. Use the lineId from GET /get-lines. When omitted, uses the line that owns the existing conversation with this number. The indicator auto-clears on the recipient's device after a short period or when a message arrives. The intended pattern is `send-typing-indicator` → wait about 2–4 seconds → `send-api-message`. ### Response On success the endpoint returns HTTP `200` with `{ status: "SENT" | "ERROR", number, error_message }` — `error_message` is null when `status` is `SENT`. Auth and request-validation failures still use standard 4xx bodies with an `error` field. Treat device-level failures (`status: "ERROR"`) as fire-and-forget — do not retry. **Request — Basic** ```bash curl -X POST https://api.tryprojectblue.com/send-typing-indicator \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "phoneNumber": "+15551234567" }' ``` **Request — Basic · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/send-typing-indicator", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "phoneNumber": "+15551234567" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — Basic · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/send-typing-indicator", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"phoneNumber": "+15551234567"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Request — Humanized sending** Show typing, wait 2–4 seconds, then send the message. ```bash # 1. Show typing curl -X POST https://api.tryprojectblue.com/send-typing-indicator \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"phoneNumber": "+15551234567"}' # 2. Wait 2–4 seconds so the dots are visible sleep 3 # 3. Send the message curl -X POST https://api.tryprojectblue.com/send-api-message \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "message": "Hey — just following up on our conversation.", "phone": "+15551234567" }' ``` **Response — SENT** ```json { "status": "SENT", "number": "+15551234567", "error_message": null } ``` **Response — ERROR** Fire-and-forget — do not retry on ERROR. ```json { "status": "ERROR", "number": "+15551234567", "error_message": "No existing iMessage conversation with this number on the selected line" } ``` # Reactions (Tapbacks) React to a specific message with one of the six standard iMessage tapbacks. Pass the `message_handle` from `/get-messages-api` or `/get-message-api` as `messageHandle`. `POST /send-reaction` > **iMessage only** > > Tapbacks only work on iMessage. SMS or RCS targets return `status: "ERROR"` with `Reactions are only supported on iMessage`. Reactions on outbound messages are not supported yet. ### Request body - `messageHandle` (string, required) — Opaque message handle from GET /get-messages-api or GET /get-message-api (message_handle). Identifies the message to react to. - `reaction` ("love" | "like" | "dislike" | "laugh" | "emphasize" | "question", required) — One of the six standard iMessage tapbacks. - `remove` (boolean) — When true, retracts a previous reaction of the same type on this message. Defaults to false. - `partIndex` (integer (>= 0)) — Which part of a multi-part message to react to. Defaults to 0. Valid `reaction` values: `love`, `like`, `dislike`, `laugh`, `emphasize`, `question`. Set `remove` to `true` to retract a previous reaction of the same type. A typical pattern is acknowledging an inbound message with `like` or `love` instead of (or before) a text reply. ### Response On success the endpoint returns HTTP `200` with `{ status: "SENT" | "ERROR", messageHandle, reaction, remove, error_message }`. Auth and request-validation failures still use standard 4xx bodies with an `error` field. **Request — Like** ```bash curl -X POST https://api.tryprojectblue.com/send-reaction \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "messageHandle": "pbm_outk6dawyUgbl-EjXCZk-g5mZnmwmSbilbaX-fvceChASMVXv1v26ONS0XENe2ggdJ82j9TMpw", "reaction": "like" }' ``` **Request — Like · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/send-reaction", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "messageHandle": "pbm_outk6dawyUgbl-EjXCZk-g5mZnmwmSbilbaX-fvceChASMVXv1v26ONS0XENe2ggdJ82j9TMpw", "reaction": "like" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — Like · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/send-reaction", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"messageHandle": "pbm_outk6dawyUgbl-EjXCZk-g5mZnmwmSbilbaX-fvceChASMVXv1v26ONS0XENe2ggdJ82j9TMpw", "reaction": "like"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Request — Remove** Retracts a previous reaction of the same type. ```bash curl -X POST https://api.tryprojectblue.com/send-reaction \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "messageHandle": "pbm_outk6dawyUgbl-EjXCZk-g5mZnmwmSbilbaX-fvceChASMVXv1v26ONS0XENe2ggdJ82j9TMpw", "reaction": "like", "remove": true }' ``` **Request — Remove · JavaScript** Retracts a previous reaction of the same type. ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/send-reaction", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "messageHandle": "pbm_outk6dawyUgbl-EjXCZk-g5mZnmwmSbilbaX-fvceChASMVXv1v26ONS0XENe2ggdJ82j9TMpw", "reaction": "like", "remove": true }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — Remove · Python** Retracts a previous reaction of the same type. ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/send-reaction", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"messageHandle": "pbm_outk6dawyUgbl-EjXCZk-g5mZnmwmSbilbaX-fvceChASMVXv1v26ONS0XENe2ggdJ82j9TMpw", "reaction": "like", "remove": True}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — SENT** ```json { "status": "SENT", "messageHandle": "pbm_outk6dawyUgbl-EjXCZk-g5mZnmwmSbilbaX-fvceChASMVXv1v26ONS0XENe2ggdJ82j9TMpw", "reaction": "like", "remove": false, "error_message": null } ``` **Response — ERROR** Device-level failure. Auth and validation failures use 4xx with an error field. ```json { "status": "ERROR", "messageHandle": "pbm_outk6dawyUgbl-EjXCZk-g5mZnmwmSbilbaX-fvceChASMVXv1v26ONS0XENe2ggdJ82j9TMpw", "reaction": "like", "error_message": "Reactions are only supported on iMessage" } ``` # List effects List the iMessage send effects accepted by `effect` on `/send-api-message`. Each entry has a `name`, `type` (`bubble` or `screen`), and a short `description`. `GET /get-effects` Bubble effects: `slam`, `loud`, `gentle`, `invisible-ink`. Screen effects: `confetti`, `balloons`, `hearts`, `lasers`, `fireworks`, `echo`, `spotlight`, `shooting-star`, `celebration`. Not available on trial accounts. **Request — cURL** ```bash curl -X GET https://api.tryprojectblue.com/get-effects \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Request — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/get-effects", { method: "GET", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}` } }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — cURL · Python** ```python import os import requests response = requests.request( "GET", "https://api.tryprojectblue.com/get-effects", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"] }, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200 OK** ```json { "effects": [ { "name": "slam", "type": "bubble", "description": "Slams the bubble onto the screen" }, { "name": "loud", "type": "bubble", "description": "Enlarges the bubble, then shrinks it" }, { "name": "gentle", "type": "bubble", "description": "Shrinks the bubble, then grows it" }, { "name": "invisible-ink", "type": "bubble", "description": "Hides the message until the recipient swipes" }, { "name": "confetti", "type": "screen", "description": "Full-screen confetti" }, { "name": "balloons", "type": "screen", "description": "Full-screen balloons" }, { "name": "hearts", "type": "screen", "description": "Full-screen hearts" }, { "name": "lasers", "type": "screen", "description": "Full-screen lasers" }, { "name": "fireworks", "type": "screen", "description": "Full-screen fireworks" }, { "name": "echo", "type": "screen", "description": "Echoes the message across the screen" }, { "name": "spotlight", "type": "screen", "description": "Spotlights the message" }, { "name": "shooting-star", "type": "screen", "description": "Full-screen shooting star" }, { "name": "celebration", "type": "screen", "description": "Full-screen celebration sparkles" } ] } ``` # Voice Calling SDK Place and receive calls on your Project Blue lines from your own web app with `@tryprojectblue/dialer`. Your API key stays on your server; the browser holds only a short-lived token scoped to one line. FaceTime Audio is a separate, native API — see [FaceTime Audio](https://api.tryprojectblue.com/docs/facetime). This section covers regular phone calls through the Project Blue dialer. Phone numbers and caller ID are managed by Project Blue; you never touch a carrier account. ## How it works 1. **Your server** calls [the token mint](https://api.tryprojectblue.com/docs/dialer-token) with your API key and a `lineId`, and forwards the response to the browser. 2. **The SDK** takes a `tokenProvider` that calls your server. It handles refresh, the call lifecycle, inbound registration, and your plan's daily minute allowance. 3. **Your UI** calls `dialer.call(number)` and listens to events on the returned call. > **Two hosts, on purpose** > > Lines come from the messaging API at `api.tryprojectblue.com/get-lines`. Tokens come from the app at `app.tryprojectblue.com/api/v1/dialer/token`. The same API key works on both. Everything else in this reference lives on the first host; only the token mint lives on the second. ## Before you start | You need | Where | | --- | --- | | An API key | Dashboard → Settings → API Keys. Server-side only. Never ship it in a browser bundle or a mobile app. | | A Dialer subscription | Dashboard → Dialer. Tokens are refused with `dialer_subscription_required` until a plan is active. | | Approved business registration | Settings → Phone Compliance. Until approved, the mint answers `dialer_not_provisioned`. | | A paid line | Trial and shared lines cannot place SDK calls. Inbound-only lines cannot either. | | A browser | The SDK is browser-only: it needs WebRTC and a microphone. Ships ESM and CommonJS with TypeScript types. | The Settings → API Keys page in the dashboard shows these same steps with your account's status filled in, so it is the fastest way to see which prerequisite is missing. **Install — npm** ```bash npm install @tryprojectblue/dialer ``` **The whole loop — server.js** Your server holds the API key and proxies the mint. ```javascript // Your server. The API key never leaves it. app.post('/dialer-token', requireLogin, async (req, res) => { const upstream = await fetch('https://app.tryprojectblue.com/api/v1/dialer/token', { method: 'POST', headers: { Authorization: `Bearer ${process.env.PROJECT_BLUE_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ lineId: req.user.projectBlueLineId }), }); // Forward status, body and the rate-limit hint as-is; the SDK understands them. // Never let a non-JSON 502/503 from a proxy throw. const retryAfter = upstream.headers.get('retry-after'); if (retryAfter) res.set('Retry-After', retryAfter); const body = await upstream .json() .catch(() => ({ error: 'Token service unavailable', code: 'dialer_unavailable' })); res.status(upstream.status).json(body); }); ``` **The whole loop — browser.ts** The browser only ever sees a 15-minute, one-line token. ```javascript import { ProjectBlueDialer, mintErrorFromResponse } from '@tryprojectblue/dialer'; const dialer = new ProjectBlueDialer({ async tokenProvider() { // Calls YOUR server, never Project Blue directly. const res = await fetch('/dialer-token', { method: 'POST' }); const body = await res.json(); const error = mintErrorFromResponse(res.status, body); if (error) throw error; return body; }, }); dialer.on('ready', ({ inboundEnabled }) => setStatus(inboundEnabled ? 'Ready' : 'Ready (outbound only)')); dialer.on('allowance', (a) => { if (a.state === 'soft') showBanner(`${a.pct}% of today's minutes used`); }); dialer.on('capReached', (error) => showBanner(error.message)); await dialer.start(); ``` # Mint a token Exchange your API key for a 15-minute voice token pinned to one line. Call this from your server whenever the SDK's `tokenProvider` asks, and return the body to the browser as-is. `POST https://app.tryprojectblue.com/api/v1/dialer/token` > **Server to server only** > > The request carries your workspace API key, so it must never be made from a browser or a mobile app. Put an authenticated route in front of it on your own backend — the snippets in the rail are complete examples — and have that route decide which `lineId` the signed-in user may call from. ### Headers `Authorization: Bearer YOUR_API_KEY` and `Content-Type: application/json`. The same key you use against `api.tryprojectblue.com`. ### Request body - `lineId` (string, required) — The line to call from, exactly as returned by GET https://api.tryprojectblue.com/get-lines with the same API key. Calls are placed from that line's number and count toward its dialer plan. Shared and trial lines are refused. ### Response - `token` (string, required) — Opaque, short-lived voice token scoped to one line. Hand the whole response body to the SDK's tokenProvider; never store the token or build on its contents. - `expiresAt` (string (ISO 8601), required) — When the token stops working. Always 15 minutes from mint. - `ttlSeconds` (number, required) — Token lifetime in seconds. Currently 900. - `lineId` (string, required) — The line this token is pinned to, echoed back. - `inboundEnabled` (boolean, required) — Whether this token can also receive calls. True only when the line has an inbound number and someone in your workspace is in its ring set. Can differ from one mint to the next. - `maxCallsPerToken` (number, required) — Outbound calls one token may place before it must be refreshed. Currently 10. The SDK refreshes ahead of this limit, so you never hit it in normal use. - `allowance` (object | null, required) — Today's minute allowance for the workspace and for this line. Null only when the plan could not be read at mint time; the token is still valid. - `state` ("ok" | "soft" | "hard", required) — ok: within plan. soft: near the included minutes — warn your users. hard is never returned on a 200; a hard stop is a 402 dialer_cap_reached refusal instead. - `used` (number, required) — Whole minutes used today across the workspace. - `included` (number, required) — Minutes included in today's plan across the workspace. - `cap` (number | null, required) — Workspace ceiling in minutes for today. Null when the account has no cap. - `pct` (number, required) — used ÷ included, as a whole percent. - `periodEnd` (string (ISO 8601), required) — When today's allowance resets — midnight UTC. A capped line resumes calling at this time. - `line` (object | null, required) — This line's own standing against its daily cap. - `used` (number, required) — Minutes this line has used today. - `cap` (number | null, required) — This line's daily cap in minutes, or null for none. - `capped` (boolean, required) — True when this line has hit its cap. The next mint for it returns 402 even if the workspace still has minutes. ## Forward it unchanged Return the upstream status, body, and `Retry-After` header to the browser exactly as received. The SDK reads `expiresAt`, `maxCallsPerToken`, `inboundEnabled`, and `allowance` to schedule its own refreshes and to raise typed errors. If you reshape the body, refresh timing and error handling degrade to defaults. Guard the `.json()` call. A proxy in front of the app can return a non-JSON `502` or `503`, and an unhandled throw in your route becomes a generic `500` in the browser instead of a retryable `token_unavailable`. ## Refusals Every non-2xx body is `{ error, code }`, plus extra fields on the cap and rate-limit cases. Unlike the messaging API, `code` is always present here, and the SDK maps it to a `DialerError` code for you. | Status | code | SDK code | Meaning | | --- | --- | --- | --- | | `401` | `invalid_api_key` | `token_unavailable` | Missing, revoked, or wrong API key. | | `400` | `invalid_line_id` | `line_unavailable` | lineId missing or not a value from /get-lines. Refused before the rate-limit slot is spent. | | `404` | `line_not_found` | `line_unavailable` | Not one of this workspace's lines. Returned for other workspaces' lines too — existence is never confirmed. | | `403` | `line_inbound_only` | `line_unavailable` | The line receives calls but cannot place them. | | `403` | `line_not_eligible` | `line_unavailable` | Shared and trial lines are not an SDK surface. | | `403` | `dialer_subscription_required` | `subscription_required` | No Dialer add-on on the workspace. | | `402` | `account_paywalled` | `account_paywalled` | The account is past due. | | `402` | `dialer_cap_reached` | `cap_reached` | The workspace or this line has used today's minutes. Body carries used, included, cap, periodEnd. | | `404` | `dialer_not_provisioned` | `not_provisioned` | Business registration (Phone Compliance) not yet approved, so calling is not provisioned. | | `403` | `api_key_unsupported` | `token_unavailable` | A legacy key that cannot mint. Create a new key in Settings → API Keys. | | `429` | `rate_limited` | `rate_limited` | Too many mints for this key. Body carries retryAfterSeconds; a Retry-After header is set. | | `500` | `dialer_misconfigured` | `token_unavailable` | Calling is not fully configured for this account. Contact support. | | `503` | `dialer_unavailable` | `token_unavailable` | Token service temporarily unavailable. Retry with backoff. | > **The mint has its own rate limit** > > This endpoint allows 30 mints per minute per API key, separate from the [60 requests per minute](https://api.tryprojectblue.com/docs/rate-limits) on the messaging API. A well-behaved SDK session mints once at start, then roughly once every 14 minutes and once per 10 calls, so the limit only matters if your server mints on every page load. Malformed requests are refused before they consume a slot. ### Status codes - **200** — Token minted - **400** — invalid_line_id - **401** — invalid_api_key - **402** — dialer_cap_reached or account_paywalled - **403** — dialer_subscription_required, line_inbound_only, line_not_eligible, api_key_unsupported - **404** — line_not_found or dialer_not_provisioned - **429** — rate_limited — read retryAfterSeconds - **500** — dialer_misconfigured or internal_error - **503** — dialer_unavailable — retry with backoff **Request — cURL** Server to server only. Note the app host. ```bash curl -X POST https://app.tryprojectblue.com/api/v1/dialer/token \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "lineId": "0b3e0c59-ff0b-4110-faf6-6f976339a8c8" }' ``` **Request — cURL · JavaScript** Server to server only. Note the app host. ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://app.tryprojectblue.com/api/v1/dialer/token", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "lineId": "0b3e0c59-ff0b-4110-faf6-6f976339a8c8" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — cURL · Python** Server to server only. Note the app host. ```python import os import requests response = requests.request( "POST", "https://app.tryprojectblue.com/api/v1/dialer/token", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"lineId": "0b3e0c59-ff0b-4110-faf6-6f976339a8c8"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Request — Express** ```javascript // Your server. The API key never leaves it. app.post('/dialer-token', requireLogin, async (req, res) => { const upstream = await fetch('https://app.tryprojectblue.com/api/v1/dialer/token', { method: 'POST', headers: { Authorization: `Bearer ${process.env.PROJECT_BLUE_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ lineId: req.user.projectBlueLineId }), }); // Forward status, body and the rate-limit hint as-is; the SDK understands them. // Never let a non-JSON 502/503 from a proxy throw. const retryAfter = upstream.headers.get('retry-after'); if (retryAfter) res.set('Retry-After', retryAfter); const body = await upstream .json() .catch(() => ({ error: 'Token service unavailable', code: 'dialer_unavailable' })); res.status(upstream.status).json(body); }); ``` **Request — Next.js** ```javascript // app/api/dialer-token/route.ts import { NextResponse } from 'next/server'; import { getSession } from '@/lib/auth'; export async function POST() { const session = await getSession(); if (!session) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); const upstream = await fetch('https://app.tryprojectblue.com/api/v1/dialer/token', { method: 'POST', headers: { Authorization: `Bearer ${process.env.PROJECT_BLUE_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ lineId: session.projectBlueLineId }), }); const body = await upstream .json() .catch(() => ({ error: 'Token service unavailable', code: 'dialer_unavailable' })); const headers = new Headers(); const retryAfter = upstream.headers.get('retry-after'); if (retryAfter) headers.set('Retry-After', retryAfter); return NextResponse.json(body, { status: upstream.status, headers }); } ``` **Response — 200 OK** ```json { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImN0eSI6InR3aWxpby1mcGE7dj0xIn0…", "expiresAt": "2026-09-04T12:15:00.000Z", "ttlSeconds": 900, "lineId": "0b3e0c59-ff0b-4110-faf6-6f976339a8c8", "inboundEnabled": true, "maxCallsPerToken": 10, "allowance": { "state": "ok", "used": 30, "included": 180, "cap": 540, "pct": 16, "periodEnd": "2026-09-05T00:00:00.000Z", "line": { "used": 30, "cap": 540, "capped": false } } } ``` **Response — 402 — cap** used/cap are the line's figures when the line is what is capped. ```json { "error": "DIALER_CAP_REACHED", "code": "dialer_cap_reached", "used": 540, "included": 180, "cap": 540, "periodEnd": "2026-09-05T00:00:00.000Z" } ``` **Response — 403 — plan** ```json { "error": "Dialer subscription required", "code": "dialer_subscription_required" } ``` **Response — 404 — line** ```json { "error": "Line not found", "code": "line_not_found" } ``` **Response — 429** A Retry-After header carries the same number. ```json { "error": "Rate limit exceeded", "code": "rate_limited", "retryAfterSeconds": 42 } ``` # The dialer session `ProjectBlueDialer` is one calling session for one line. Create it with a `tokenProvider`, call `start()`, and keep it alive for as long as the user can place or receive calls. ### Options - `tokenProvider` (() => Promise, required) — Called whenever the SDK needs a token: at start(), before expiry, and before a token's call limit is reached. Must call your own server. Return the mint response body as-is (recommended), or just the token string. To surface a refusal, throw mintErrorFromResponse(status, body) — or return the error body with its HTTP status added. - `refreshLeadSeconds` (number) — Refresh the token this many seconds before it expires. Minimum 5. Tokens live 15 minutes, so keep it well under that. - `logger` (console-like | null) — Where the SDK logs. Pass an object with debug/info/warn/error, or null to silence it entirely. - `edge` (string | string[]) — Preferred media region, e.g. "ashburn" or ["ashburn", "roaming"]. Leave unset unless you have measured a reason to pin one. - `playIncomingRingtone` (boolean) — Play a ringtone in the browser when an inbound call arrives. Set false to render your own. ## Writing the tokenProvider It runs whenever the SDK needs a token: at `start()`, about a minute before the current token expires, and before a token has been used for its tenth call. It must call **your** server, never the mint directly. Return the mint body unchanged. To report a refusal, throw `mintErrorFromResponse(res.status, body)` — it returns `null` on a 2xx and the matching typed error otherwise, so the three-line pattern in the rail is the whole thing. If you would rather return the error body, add `status` to it first; without it the SDK reports `402` for a cap refusal and `400` for everything else. ## Methods | Method | Returns | Notes | | --- | --- | --- | | `start()` | `Promise` | Fetches the first token and connects. Resolves once calls can be placed. Calling it twice is a no-op. | | `call(to)` | `Promise` | Places an outbound call. `to` must be E.164 **with** the leading `+`; spaces, dashes and parentheses are stripped, but a country code is never guessed. One call at a time — a second `call()` while one is active throws `invalid_state`. | | `refreshToken()` | `Promise` | Forces a refresh now. Usually unnecessary; concurrent calls share one in-flight refresh. | | `destroy()` | `Promise` | Hangs up any call, stops refreshing, releases the microphone, and removes all listeners. Idempotent. Call it on logout or unmount. | | `isReady()` | `boolean` | Started, not destroyed, and holding a token. | ### Getters | Property | Type | Notes | | --- | --- | --- | | `allowance` | `DialerAllowance \| null` | The latest allowance the server sent with a token. Null before `start()`. | | `inboundEnabled` | `boolean` | Whether the current token lets this session receive calls. | | `activeCall` | `DialerCall \| null` | The call in progress, if any. | ## Events Subscribe with `dialer.on(event, handler)`; `off` and `once` work the same way. | Event | Payload | When | | --- | --- | --- | | `ready` | `{ inboundEnabled }` | Calls can be placed. Fires again after every successful token refresh, with the current inbound state. | | `allowance` | `DialerAllowance` | A fresh allowance arrived with a token. Warn users on state: "soft". | | `capReached` | `DialerCapReachedError` | The workspace or line hit its cap. No new tokens until periodEnd; a call in progress continues. | | `incoming` | `DialerCall` | Someone is calling the line this session is scoped to. Call accept() or reject(). | | `tokenRefreshFailed` | `DialerError` | A background refresh failed. The session keeps its current token until it expires and retries with backoff. | | `error` | `DialerError` | Session-level error, e.g. inbound registration failed. Calls carry their own error events. | | `destroyed` | `—` | destroy() completed. | ## Token refresh, in detail You never manage tokens directly, but knowing the schedule explains what your server will see. The session refreshes 60 seconds before expiry by default, immediately before the call that would exceed `maxCallsPerToken`, and whenever the voice service reports the token invalid. A failed refresh emits `tokenRefreshFailed` and retries after 5, 15, then 45 seconds; the current token keeps working until it expires. A `cap_reached` refusal is different: the session emits `capReached`, stops retrying, and wakes itself one second after `periodEnd`. A call that is already up is never cut off — caps apply at mint time only. **Start a session — browser.ts** ```javascript import { ProjectBlueDialer, mintErrorFromResponse } from '@tryprojectblue/dialer'; const dialer = new ProjectBlueDialer({ async tokenProvider() { // Calls YOUR server, never Project Blue directly. const res = await fetch('/dialer-token', { method: 'POST' }); const body = await res.json(); const error = mintErrorFromResponse(res.status, body); if (error) throw error; return body; }, }); dialer.on('ready', ({ inboundEnabled }) => setStatus(inboundEnabled ? 'Ready' : 'Ready (outbound only)')); dialer.on('allowance', (a) => { if (a.state === 'soft') showBanner(`${a.pct}% of today's minutes used`); }); dialer.on('capReached', (error) => showBanner(error.message)); await dialer.start(); ``` **Tear down — browser.ts** ```javascript // On logout, route change or component unmount. // Hangs up any call, stops refreshing, releases the microphone. Idempotent. await dialer.destroy(); ``` # Calls A `DialerCall` is one call. Outbound calls come back from `dialer.call()`; inbound calls arrive on the session's `incoming` event and must be accepted or rejected. ### Fields | Field | Type | Notes | | --- | --- | --- | | `direction` | `"outbound" \| "inbound"` | Which way the call was placed. | | `remoteNumber` | `string \| null` | The number you dialed, or the caller's number, in E.164 when known. | | `callerName` | `string \| null` | Inbound only. The caller's display name from your CRM, when the line has one. | | `lineName` | `string \| null` | Inbound only. The name of the line being called. | ### Methods | Method | Notes | | --- | --- | | `accept()` | Inbound only. Answer the call. | | `reject()` | Inbound only. Decline without answering. | | `hangup()` | End the call from your side. | | `mute(shouldMute = true)` | Mute or unmute the microphone. Emits `mute`. | | `isMuted()` | Current mute state. | | `sendDigits(digits)` | DTMF tones for phone menus, e.g. `"1"` or `"123#"`. | | `status()` | One of the statuses below. | | `isActive()` | True from `connecting` through `reconnecting`; false once `closed`. | ### status() values `pending`, `connecting`, `ringing`, `open`, `reconnecting`, `closed` | Value | Meaning | | --- | --- | | `pending` | Created, no signaling yet. | | `connecting` | Signaling in progress. | | `ringing` | The remote side is being rung. | | `open` | Media is flowing. | | `reconnecting` | Lost the connection and trying to recover. | | `closed` | Ended. | ## Events | Event | Payload | When | | --- | --- | --- | | `ringing` | `{ hasEarlyMedia }` | Outbound: the remote side is being rung. hasEarlyMedia means carrier audio is already playing. | | `accepted` | `—` | Media is flowing. | | `disconnected` | `—` | The call ended, by either side. | | `cancelled` | `—` | Inbound: the caller hung up before you answered. | | `rejected` | `—` | You called reject(), or the remote side declined. | | `error` | `DialerError` | The call failed. | | `reconnecting` | `DialerError` | Connection lost; the SDK is trying to recover. | | `reconnected` | `—` | Recovered. | | `mute` | `boolean` | Mute state changed. | | `warning` | `string` | Non-fatal media quality warning, e.g. high-jitter. | | `warningCleared` | `string` | A previous warning cleared. | Exactly one of `disconnected`, `cancelled`, or `rejected` fires when a call ends, and never more than once. Clear your UI on all three. ## Inbound calls A session receives calls only while its token was minted with `inboundEnabled: true`. That requires the line to have an inbound number and at least one person in your workspace in its ring set; the SDK then rings **alongside** them, never instead of them. A line with nobody in its ring set still answers "no one is available", SDK or not. Because `inboundEnabled` is evaluated at every mint, it can change mid-session. Read the value from each `ready` event rather than caching it at start, and show an inbound UI only when it is true. > **Answering needs a user gesture** > > Browsers block audio until the page has been interacted with. Wire `accept()` to a button the user clicks; do not auto-answer from the `incoming` handler. **Outbound — browser.ts** ```javascript const call = await dialer.call('+15551234567'); // E.164, leading + required call.on('ringing', ({ hasEarlyMedia }) => setStatus(hasEarlyMedia ? 'Ringing…' : 'Connecting…')); call.on('accepted', () => setStatus('Connected')); call.on('disconnected', () => setStatus('Ended')); call.on('reconnecting', () => setStatus('Reconnecting…')); call.on('warning', (name) => console.warn('call quality:', name)); muteButton.onclick = () => call.mute(!call.isMuted()); keypad.onpress = (digit) => call.sendDigits(digit); hangupButton.onclick = () => call.hangup(); ``` **Inbound — browser.ts** Only fires when the token was minted with inboundEnabled: true. ```javascript dialer.on('incoming', (call) => { showIncomingUi(call.remoteNumber, call.callerName, call.lineName, { answer: () => call.accept(), decline: () => call.reject(), }); call.on('cancelled', hideIncomingUi); // caller hung up before you answered call.on('accepted', () => setStatus('Connected')); call.on('disconnected', () => setStatus('Ended')); }); ``` # Errors & limits Every rejection from the SDK is a `DialerError` with a stable `code`, the HTTP `status` of the mint response when there was one, and the original `cause`. Two subclasses carry extra fields. ### Classes | Class | code | Extra fields | | --- | --- | --- | | `DialerError` | any below | `code, status, cause` | | `DialerCapReachedError` | `cap_reached` | `used, included, cap, periodEnd (Date)` | | `DialerRateLimitedError` | `rate_limited` | `retryAfterSeconds` | ### Codes | code | Meaning | | --- | --- | | `cap_reached` | Daily minute cap hit. DialerCapReachedError with used, included, cap, periodEnd. Nothing to retry until periodEnd. | | `rate_limited` | Your server is minting too fast for this key. DialerRateLimitedError with retryAfterSeconds. | | `subscription_required` | No Dialer add-on on the workspace. | | `account_paywalled` | The account is past due. | | `line_unavailable` | The line id is unknown, not yours, inbound-only, or a shared/trial line. | | `not_provisioned` | Business registration not yet approved. | | `token_unavailable` | The tokenProvider threw, returned something that was not a token, or the mint failed for another reason. | | `invalid_state` | call() before start(), after destroy(), or while another call is in progress. | | `microphone_unavailable` | The browser denied microphone access or has no input device. | | `connection_failed` | Could not reach the voice service. | | `call_failed` | Anything else, including a malformed number passed to call(). See error.cause. | The mapping from the mint's server codes to these is in [Mint a token](https://api.tryprojectblue.com/docs/dialer-token). Branch on `code` or use `instanceof` for the two subclasses; do not match on `message`, which is written for end users and may change. ## Plans, caps and minutes Every call is metered against your Dialer plan in whole minutes. The allowance that arrives with each token tells you where you stand today, for the workspace and for the token's line. Three things follow from it: 1. **Soft threshold.** `allowance.state` becomes `"soft"` as you approach the included minutes. Nothing is refused; show a banner. 2. **Hard stop.** When the workspace or this line reaches its daily cap, the next mint returns `402 dialer_cap_reached` and the SDK emits `capReached`. New calls fail at the mint; calls in progress continue. The session resumes on its own after `periodEnd`, midnight UTC. 3. **Per-line caps.** A capped line is a hard stop for tokens pinned to it even while other lines on the account keep calling. In that case `used` and `cap` in the 402 body are the line's figures, not the workspace's. ## Limits | Limit | Value | What happens | | --- | --- | --- | | Token lifetime | `15 min` | SDK refreshes 60 s early by default (`refreshLeadSeconds`). | | Calls per token | `10` | SDK refreshes before the eleventh call; a well-behaved client never hits this. | | Mints per API key | `30 / min` | `429 rate_limited` with `retryAfterSeconds`. Separate from the messaging API's 60 / min. | | Concurrent calls per session | `1` | `call()` throws `invalid_state` while one is active. Open a second session for a second simultaneous call. | | Daily minutes | `per plan` | Read `allowance`. Resets at midnight UTC. | > **Package** > > [`@tryprojectblue/dialer` on npm](https://www.npmjs.com/package/@tryprojectblue/dialer), MIT licensed, ESM + CJS with bundled types, no framework dependency. Its README repeats the essentials of this section. **Handle errors — browser.ts** ```javascript import { DialerError, DialerCapReachedError, DialerRateLimitedError } from '@tryprojectblue/dialer'; try { await dialer.call(number); } catch (error) { if (error instanceof DialerCapReachedError) { // Nothing to retry until error.periodEnd (midnight UTC). disableDialPad(`Daily minutes used. Calling resumes ${error.periodEnd?.toLocaleTimeString()}.`); } else if (error instanceof DialerRateLimitedError) { setTimeout(retry, error.retryAfterSeconds * 1000); } else if (error instanceof DialerError && error.code === 'microphone_unavailable') { showBanner('Allow microphone access to place calls.'); } else if (error instanceof DialerError) { showBanner(error.message); // error.code, error.status, error.cause } else { throw error; } } ``` # Call logs Returns the authenticated user's dialer call logs, inbound and outbound, including a `recording_url` when a recording is available. This is the call log analog of `/get-messages-api`. `GET /get-call-logs-api` > **Inbound and outbound** > > Omit `direction` to return inbound and outbound calls. Pass `direction=outbound` to get the previous outbound only behavior. Inbound rows include missed calls and voicemails. A voicemail's audio is in `recording_url` and its text is in `transcript`. > **recording_url can be null — that's expected** > > This endpoint reports call **attempts**, not just recorded calls — so unanswered, busy, failed, and very short calls all show up with `recording_url: null`. Answered calls typically populate `recording_url` within seconds of `ended_at`.If a long-completed call still has `recording_url: null`, it usually means no audio was captured for that call (e.g. recording disabled on the line). ### Query parameters - `limit` (integer (1–100)) — Maximum number of call logs to return. Defaults to 100. - `offset` (integer (≥ 0)) — Pagination offset. Defaults to 0. offset + limit must be ≤ 2000; deeper pages return 400 regardless of limit. - `call_log_timestamp` ("asc" | "desc") — Sort direction by the call log's created_at, so unanswered attempts interleave with answered calls. Defaults to desc (newest first). - `pb_line_id` (string (UUID)) — Encoded Project Blue line id (from GET /get-lines). Returns 400 if the line does not belong to the API key's user. - `direction` ("inbound" | "outbound") — Filter to inbound or outbound only. Omit for both. - `answered_at_gte` (string (ISO-8601)) — Inclusive lower bound on answered_at. Note: only matches calls that were actually answered. - `answered_at_lte` (string (ISO-8601)) — Inclusive upper bound on answered_at. Note: only matches calls that were actually answered. ### CallLog object - `id` (string, required) — Internal call log id (stable, useful for dedupe). - `line_id` (string | null, required) — UUID-encoded PB line id. Round-trips with the pb_line_id filter. - `direction` ("inbound" | "outbound", required) — Whether the call was received on the user's line or placed from it. - `from_number` (string, required) — E.164. On outbound rows this is the user's line. On inbound rows this is the caller. - `to_number` (string, required) — E.164. On outbound rows this is the number dialed. On inbound rows this is the user's line. - `status` (string, required) — Call status (completed, no-answer, busy, failed, canceled, …). - `disposition` (string | null, required) — AI-assigned disposition derived from the call transcript. See the Dispositions table below for all possible values. - `transcript` (string | null, required) — Speaker-labelled transcript when one was generated. - `duration_seconds` (number | null, required) — Connected duration. null for calls that never connected. - `answered_at` (string (ISO-8601) | null, required) — When the call was answered. - `ended_at` (string (ISO-8601) | null, required) — When the call ended. - `recording_url` (string | null, required) — URL to the call recording when one is available; null otherwise. ## Dispositions After a recording is transcribed, the transcript is run through an AI classifier that assigns one of the following dispositions. Use this for routing, follow-up automation, or analytics. The disposition can be `null` on calls that haven't been classified yet. | Value | Meaning | | --- | --- | | `answered` | A human answered and spoke (any clear human speech that isn't a voicemail greeting). | | `voicemail` | The call went to voicemail (voicemail greeting, beep, or 'leave a message' prompt detected). | | `busy` | The line was busy. | | `no_answer` | No one answered — just ringing or silence. | | `wrong_number` | The person on the other end indicated this is the wrong number. | | `not_interested` | The person explicitly declined or showed no interest. | | `callback_requested` | The person asked to be called back at a later time. | | `meeting_scheduled` | A meeting or appointment was scheduled on the call. | | `information_provided` | Information was exchanged but no clear next step was set. | | `no_speech` | The transcript was empty (no speech to classify). | | `unknown` | Truly cannot determine from the transcript. Used sparingly. | ### Status codes - **200** — Call logs returned - **400** — Invalid query parameter (limit/offset/call_log_timestamp/dates/pb_line_id/direction) - **401** — Missing or invalid API key - **429** — Rate limit exceeded - **500** — Internal server error **Request — cURL** ```bash curl -G https://api.tryprojectblue.com/get-call-logs-api \ -H "Authorization: Bearer YOUR_API_KEY" \ --data-urlencode "pb_line_id=6121307b-c29e-41d5-426b-46b679ab8648" \ --data-urlencode "answered_at_gte=2026-04-01T00:00:00Z" \ --data-urlencode "answered_at_lte=2026-05-01T00:00:00Z" \ --data-urlencode "call_log_timestamp=asc" \ --data-urlencode "limit=50" ``` **Request — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const url = new URL("https://api.tryprojectblue.com/get-call-logs-api"); url.searchParams.append("pb_line_id", "6121307b-c29e-41d5-426b-46b679ab8648"); url.searchParams.append("answered_at_gte", "2026-04-01T00:00:00Z"); url.searchParams.append("answered_at_lte", "2026-05-01T00:00:00Z"); url.searchParams.append("call_log_timestamp", "asc"); url.searchParams.append("limit", "50"); const response = await fetch(url, { method: "GET", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}` } }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — cURL · Python** ```python import os import requests response = requests.request( "GET", "https://api.tryprojectblue.com/get-call-logs-api", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"] }, params=[("pb_line_id", "6121307b-c29e-41d5-426b-46b679ab8648"), ("answered_at_gte", "2026-04-01T00:00:00Z"), ("answered_at_lte", "2026-05-01T00:00:00Z"), ("call_log_timestamp", "asc"), ("limit", "50")], timeout=30, ) response.raise_for_status() print(response.json()) ``` **Request — Pagination** ```bash # page 1 curl ".../get-call-logs-api?limit=100&offset=0" # page 2 curl ".../get-call-logs-api?limit=100&offset=100" # stop when data.length < limit, or offset >= pagination.total ``` **Request — Last 24h** Calls for one line in the last day. ```bash GTE=$(date -u -v-24H +"%Y-%m-%dT%H:%M:%SZ") # macOS curl -sS \ -H "Authorization: Bearer $PB_API_KEY" \ "https://api.tryprojectblue.com/get-call-logs-api?pb_line_id=$LINE_ID&answered_at_gte=$GTE" ``` **Request — Inbound only** ```bash curl -G https://api.tryprojectblue.com/get-call-logs-api \ -H "Authorization: Bearer YOUR_API_KEY" \ --data-urlencode "direction=inbound" \ --data-urlencode "limit=50" ``` **Request — Inbound only · JavaScript** ```javascript // Run on your server. Keep your API key private. const url = new URL("https://api.tryprojectblue.com/get-call-logs-api"); url.searchParams.append("direction", "inbound"); url.searchParams.append("limit", "50"); const response = await fetch(url, { method: "GET", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}` } }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — Inbound only · Python** ```python import os import requests response = requests.request( "GET", "https://api.tryprojectblue.com/get-call-logs-api", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"] }, params=[("direction", "inbound"), ("limit", "50")], timeout=30, ) response.raise_for_status() print(response.json()) ``` **Request — By disposition** The endpoint has no disposition filter — filter client-side. ```bash curl -sS -H "Authorization: Bearer $PB_API_KEY" \ "https://api.tryprojectblue.com/get-call-logs-api?limit=100" \ | jq '.data | map(select(.disposition == "answered"))' ``` **Response — 200 OK** ```json { "status": "OK", "data": [ { "id": "cmorpmiw5fyb513ynkuz8jr39", "line_id": "6121307b-c29e-41d5-426b-46b679ab8648", "direction": "outbound", "from_number": "+16027184932", "to_number": "+18016966474", "status": "completed", "disposition": "answered", "transcript": "Speaker A: Hey Colton, how are you?\nSpeaker B: This is Camila from Project Blue…", "duration_seconds": 168, "answered_at": "2026-05-04T21:24:06.882Z", "ended_at": "2026-05-04T21:26:53.882Z", "recording_url": "https:///call-recordings/<...>.mp3" }, { "id": "cmorvmw8abcd13ynxxxxxxxx", "line_id": "6121307b-c29e-41d5-426b-46b679ab8648", "direction": "inbound", "from_number": "+18016966474", "to_number": "+16027184932", "status": "completed", "disposition": "voicemail", "transcript": "Hey, this is Colton. Give me a call back when you can.", "duration_seconds": 18, "answered_at": "2026-05-04T19:02:11.000Z", "ended_at": "2026-05-04T19:02:29.000Z", "recording_url": "https:///call-recordings/<...>.mp3" }, { "id": "cmorbzz12abcd13ynxxxxxxxx", "line_id": "6121307b-c29e-41d5-426b-46b679ab8648", "direction": "outbound", "from_number": "+16027184932", "to_number": "+18015550199", "status": "no-answer", "disposition": null, "transcript": null, "duration_seconds": null, "answered_at": null, "ended_at": "2026-05-04T20:11:08.000Z", "recording_url": null } ], "pagination": { "limit": 100, "offset": 0, "total": 910 } } ``` **Response — 400 — line** ```json { "error": "Invalid or unavailable pb_line_id for this API key user." } ``` **Response — 400 — date** ```json { "error": "answered_at_gte is not a valid ISO-8601 date" } ``` **Response — 400 — depth** offset + limit may not exceed 2000. ```json { "error": "Pagination depth too deep. offset+limit must be <= 2000" } ``` # FaceTime Audio Initiate real FaceTime Audio calls programmatically and connect to the live call audio via WebRTC using Agora's SDK. The `pb_line_id` must be a FaceTime-enabled line on your account. `POST /start-facetime-call-api` > **FaceTime-enabled accounts only** > > These endpoints are available only on API accounts with FaceTime Audio enabled. Calls from accounts without the feature return 403 with error code `FACETIME_NOT_ENABLED` — that means the feature isn't active on your account, not that the API is down. Interested in FaceTime Audio? Contact [sales@tryprojectblue.com](mailto:sales@tryprojectblue.com) or reach out to support to upgrade. ### Request body - `pb_line_id` (string (UUID), required) — FaceTime-enabled line to call from. UUID returned from GET /get-lines. - `phone_number` (string (E.164), required) — Destination phone number. Flexible formats accepted; normalized to E.164. ### Response - `status` ("OK", required) — Present on every successful call. - `call_uuid` (string, required) — Identifies the call. Pass it to the status and end endpoints. - `agora` (object | null, required) — WebRTC credentials for joining the call audio, or null when the device placed the call but returned no credentials. The call is still ringing in that case — you simply cannot join its audio, so check for null before calling the Agora SDK. - `appId` (string, required) — Agora application id. - `channelName` (string, required) — Channel to join for this call. - `token` (string, required) — Time-limited RTC token. Join promptly after starting the call. - `uid` (number, required) — The uid to join as. ## Joining the call The returned `agora` credentials are used with the Agora Voice SDK to stream audio to and from the FaceTime call. Tokens are time-limited, so join the channel promptly after starting the call. > **agora can be null on a 200** > > A `200` means the call was placed, not that you can hear it. When the device returns no credentials, `agora` is `null` and the call still rings — check for it before touching the SDK, and fall back to polling [`/get-facetime-call-status-api`](https://api.tryprojectblue.com/docs/facetime-status) for the outcome. **Request — cURL** ```bash curl -X POST https://api.tryprojectblue.com/start-facetime-call-api \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "pb_line_id": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "phone_number": "+15551234567" }' ``` **Request — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/start-facetime-call-api", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "pb_line_id": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "phone_number": "+15551234567" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — cURL · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/start-facetime-call-api", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"pb_line_id": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "phone_number": "+15551234567"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200 OK** ```json { "status": "OK", "call_uuid": "ftc_8a2b1c3d4e5f6g7h", "agora": { "appId": "your-agora-app-id", "channelName": "facetime-channel-abc123", "token": "agora-rtc-token...", "uid": 123456 } } ``` **Join the call — JavaScript** Tokens are time-limited — join promptly. Check res.agora is non-null first. ```javascript import AgoraRTC from "agora-rtc-sdk-ng"; const client = AgoraRTC.createClient({ mode: "rtc", codec: "vp8" }); await client.join( res.agora.appId, res.agora.channelName, res.agora.token, res.agora.uid, ); const mic = await AgoraRTC.createMicrophoneAudioTrack(); await client.publish([mic]); client.on("user-published", async (user, mediaType) => { await client.subscribe(user, mediaType); if (mediaType === "audio") user.audioTrack.play(); }); ``` # FaceTime call status Status is driven by call lifecycle events. Poll this endpoint to track `ringing` → `answered` → `ended`. `GET /get-facetime-call-status-api` ### Query parameters - `call_uuid` (string, required) — The call_uuid returned by POST /start-facetime-call-api, or from an inbound FaceTime webhook. ### Response - `status` ("OK", required) — Present on every successful read. - `call_uuid` (string, required) — Identifies the call. - `call_status` (string, required) — Live status. Inbound values: ringing, answered, ended, declined, no_answer, voicemail, busy, failed. - `direction` ("inbound" | "outbound", required) — Whether the call was received on your line or placed from it. - `address` (string, required) — The other party's number in E.164. - `ringing_at` (string (ISO 8601) | null, required) — When the call started ringing, or null if it has not. - `answered_at` (string (ISO 8601) | null, required) — When the call was answered, or null if it never was. - `ended_at` (string (ISO 8601) | null, required) — When the call reached a terminal state, or null if it has not. ### call_status values `initiated`, `ringing`, `answered`, `ended`, `declined`, `no_answer`, `voicemail`, `busy`, `failed` **Request — cURL** ```bash curl -G https://api.tryprojectblue.com/get-facetime-call-status-api \ -H "Authorization: Bearer YOUR_API_KEY" \ --data-urlencode "call_uuid=ftc_8a2b1c3d4e5f6g7h" ``` **Request — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const url = new URL("https://api.tryprojectblue.com/get-facetime-call-status-api"); url.searchParams.append("call_uuid", "ftc_8a2b1c3d4e5f6g7h"); const response = await fetch(url, { method: "GET", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}` } }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — cURL · Python** ```python import os import requests response = requests.request( "GET", "https://api.tryprojectblue.com/get-facetime-call-status-api", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"] }, params=[("call_uuid", "ftc_8a2b1c3d4e5f6g7h")], timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200 OK** ```json { "status": "OK", "call_uuid": "ftc_8a2b1c3d4e5f6g7h", "call_status": "answered", "direction": "outbound", "address": "+15551234567", "ringing_at": null, "answered_at": "2026-07-18T18:04:12.000Z", "ended_at": null } ``` # End a FaceTime call `POST /end-facetime-call-api` ### Request body - `call_uuid` (string, required) — The call_uuid returned by POST /start-facetime-call-api, or from an inbound FaceTime webhook. > **Daily dial limit** > > Each account may dial up to 40 unique destinations per calendar day (America/Los_Angeles). Redials to a number already called that day do not count. Exceeding the limit returns 429 with `error_code: FACETIME_DAILY_LIMIT_REACHED` plus `uniqueDestinationsToday` and `limit` fields. ### Status codes - **200** — Call started / status returned - **400** — Invalid pb_line_id or phone_number - **401** — Missing or invalid API key - **403** — FACETIME_NOT_ENABLED — FaceTime Audio not enabled on this account - **404** — Call not found (status/end endpoints) - **429** — Rate limit exceeded or daily FaceTime dial limit reached - **502** — Device error placing the call - **500** — Internal server error **Request — cURL** ```bash curl -X POST https://api.tryprojectblue.com/end-facetime-call-api \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "call_uuid": "ftc_8a2b1c3d4e5f6g7h" }' ``` **Request — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/end-facetime-call-api", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "call_uuid": "ftc_8a2b1c3d4e5f6g7h" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — cURL · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/end-facetime-call-api", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"call_uuid": "ftc_8a2b1c3d4e5f6g7h"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200 OK** ```json { "status": "OK" } ``` # Inbound FaceTime calls If you are building your own CRM or softphone, you can receive inbound FaceTime Audio calls on your lines, show a ring screen, and answer or decline from your own UI. Answering returns Agora credentials, so the same join code as outbound calls applies. `POST /answer-facetime-call-api` > **FaceTime-enabled accounts only** > > These endpoints are available only on API accounts with FaceTime Audio enabled. Calls from accounts without the feature return 403 with error code `FACETIME_NOT_ENABLED` — that means the feature isn't active on your account, not that the API is down. Interested in FaceTime Audio? Contact [sales@tryprojectblue.com](mailto:sales@tryprojectblue.com) or reach out to support to upgrade. ## How it fits together 1. A `facetime.inbound.ringing` webhook arrives when a call rings on one of your lines. 2. Your UI shows a ring screen keyed on `call_uuid`. 3. You answer or decline via the API. 4. On answer you join Agora with the returned credentials. 5. `facetime.inbound.answered` and `facetime.inbound.ended` webhooks keep your UI in sync. 6. You hang up with [`/end-facetime-call-api`](https://api.tryprojectblue.com/docs/facetime-end). ## 1. Turn on call events for a webhook In the Project Blue app go to Settings > API Webhooks, click Add Webhook, tick `Inbound FaceTime calls`, then Test & Save. Existing webhooks cannot be edited, so create a new one or a second one to the same URL. The calls box is off by default, so existing message automations are not affected. ## 2. Handle the ringing event When an inbound FaceTime Audio call starts ringing on one of your lines, Project Blue POSTs `facetime.inbound.ringing`. Key your UI on `call_uuid`. A repeated ringing signal from the Mac produces one ringing webhook per call. - `event` ("facetime.inbound.ringing", required) — Fired when an inbound FaceTime Audio call starts ringing on one of your lines. - `call_uuid` (string, required) — Identifies the call. Key your UI on this value and pass it to answer or decline. - `direction` ("inbound", required) — Always inbound for this event. - `from` (string, required) — The caller in E.164. - `pb_line_id` (string (UUID), required) — The same UUID v4 lineId returned by GET /get-lines. - `linePhoneNumber` (string, required) — The customer line that was called, in E.164. - `ringingAt` (string (ISO 8601), required) — When the call started ringing, UTC. - `receivedAt` (string (ISO 8601), required) — When Project Blue emitted this webhook, UTC. ### Request body - `call_uuid` (string, required) — The call_uuid from the facetime.inbound.ringing webhook. The call must be inbound and ringing. ### Response - `success` (boolean, required) — true when the device accepted the answer. - `call_uuid` (string, required) — Echo of the call you answered. - `agora` (object | null, required) — WebRTC credentials for joining the call audio. Comes from the Mac at answer time; if the Mac returns none, the service falls back to the credentials stored when the call started ringing. Can still be null on a 200. Check for null before joining. - `appId` (string, required) — Agora application id. - `channelName` (string, required) — Channel to join for this call. - `token` (string, required) — RTC token. Join promptly after answering. - `uid` (number, required) — The uid to join as. > **agora can be null on a 200** > > A `200` means the call was answered, not that you can hear it. `agora` comes from the Mac at answer time; if the Mac returns none, the service falls back to the credentials it stored when the call started ringing. It can still be `null` on a `200`. Check for it before touching the SDK. `POST /decline-facetime-call-api` ### Request body - `call_uuid` (string, required) — The call_uuid from the facetime.inbound.ringing webhook. The call must be inbound and ringing. If the caller already hung up between the webhook and the decline, the service treats already disconnected from the Mac as success. ## 3. Keep your UI in sync `facetime.inbound.answered` means someone else picked up. Dismiss the ring UI if you were not the one that answered. - `event` ("facetime.inbound.answered", required) — Fired when the call is answered by anyone: the API, the Project Blue mobile app, or the web app. - `call_uuid` (string, required) — Identifies the call. - `from` (string, required) — The caller in E.164. - `pb_line_id` (string (UUID), required) — The same UUID v4 lineId returned by GET /get-lines. - `linePhoneNumber` (string, required) — The customer line that was called, in E.164. - `answeredAt` (string (ISO 8601), required) — When the call was answered, UTC. - `receivedAt` (string (ISO 8601), required) — When Project Blue emitted this webhook, UTC. `facetime.inbound.ended` means the call is over. Tear down the ring UI and leave the Agora channel. - `event` ("facetime.inbound.ended", required) — Fired when the call reaches a terminal state. - `call_uuid` (string, required) — Identifies the call. - `status` ("ended" | "declined" | "no_answer" | "voicemail" | "busy" | "failed", required) — The terminal state. - `from` (string, required) — The caller in E.164. - `pb_line_id` (string (UUID), required) — The same UUID v4 lineId returned by GET /get-lines. - `linePhoneNumber` (string, required) — The customer line that was called, in E.164. - `answeredAt` (string (ISO 8601) | null, required) — When the call was answered, UTC. null when the call was never answered (declined, no_answer, voicemail, busy, failed). - `endedAt` (string (ISO 8601), required) — When the call reached a terminal state, UTC. - `receivedAt` (string (ISO 8601), required) — When Project Blue emitted this webhook, UTC. ## Events | Event | When it fires | Notes | | --- | --- | --- | | `facetime.inbound.ringing` | An inbound FaceTime Audio call starts ringing on one of your lines. | One ringing event per call, even if the Mac repeats the signal. Key your UI on call_uuid. | | `facetime.inbound.answered` | The call is answered by anyone (the API, the Project Blue mobile app, or the web app). | Dismiss your ring UI if you were not the one that answered. | | `facetime.inbound.ended` | The call reaches a terminal state. | status is one of ended, declined, no_answer, voicemail, busy, failed. answeredAt is null when the call was never answered. | > **No retries, so reconcile on miss** > > If your endpoint misses the ringing event, poll [`/get-facetime-call-status-api`](https://api.tryprojectblue.com/docs/facetime-status) for any `call_uuid` you learn about later. A call is answerable only while `call_status` is `ringing`. ### Status codes - **200** — Call answered / declined - **400** — Invalid or missing call_uuid - **401** — Missing or invalid API key - **403** — FACETIME_NOT_ENABLED - **404** — Call not found - **409** — Call is not an inbound call that is currently ringing - **429** — Rate limit exceeded - **502** — Device error - **503** — Device unreachable - **500** — Internal server error **Webhook events — Ringing** ```json { "event": "facetime.inbound.ringing", "call_uuid": "ftc_8a2b1c3d4e5f6g7h", "direction": "inbound", "from": "+15551234567", "pb_line_id": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "linePhoneNumber": "+15559876543", "ringingAt": "2026-09-15T18:04:02.000Z", "receivedAt": "2026-09-15T18:04:02.310Z" } ``` **Webhook events — Answered** ```json { "event": "facetime.inbound.answered", "call_uuid": "ftc_8a2b1c3d4e5f6g7h", "from": "+15551234567", "pb_line_id": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "linePhoneNumber": "+15559876543", "answeredAt": "2026-09-15T18:04:09.000Z", "receivedAt": "2026-09-15T18:04:09.280Z" } ``` **Webhook events — Ended** ```json { "event": "facetime.inbound.ended", "call_uuid": "ftc_8a2b1c3d4e5f6g7h", "status": "ended", "from": "+15551234567", "pb_line_id": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "linePhoneNumber": "+15559876543", "answeredAt": "2026-09-15T18:04:09.000Z", "endedAt": "2026-09-15T18:07:41.000Z", "receivedAt": "2026-09-15T18:07:41.190Z" } ``` **Answer — cURL** ```bash curl -X POST https://api.tryprojectblue.com/answer-facetime-call-api \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "call_uuid": "ftc_8a2b1c3d4e5f6g7h" }' ``` **Answer — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/answer-facetime-call-api", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "call_uuid": "ftc_8a2b1c3d4e5f6g7h" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Answer — cURL · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/answer-facetime-call-api", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"call_uuid": "ftc_8a2b1c3d4e5f6g7h"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Answer — 200 OK** ```json { "success": true, "call_uuid": "ftc_8a2b1c3d4e5f6g7h", "agora": { "appId": "your-agora-app-id", "channelName": "facetime-channel-abc123", "token": "agora-rtc-token...", "uid": 123456 } } ``` **Answer — 409** Only a ringing inbound call can be answered. ```json { "error": "Call is not ringing" } ``` **Decline — cURL** ```bash curl -X POST https://api.tryprojectblue.com/decline-facetime-call-api \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "call_uuid": "ftc_8a2b1c3d4e5f6g7h" }' ``` **Decline — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/decline-facetime-call-api", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "call_uuid": "ftc_8a2b1c3d4e5f6g7h" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Decline — cURL · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/decline-facetime-call-api", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"call_uuid": "ftc_8a2b1c3d4e5f6g7h"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Decline — 200 OK** ```json { "success": true, "call_uuid": "ftc_8a2b1c3d4e5f6g7h" } ``` **Join the call — JavaScript** Tokens are time-limited — join promptly. Check res.agora is non-null first. ```javascript import AgoraRTC from "agora-rtc-sdk-ng"; const client = AgoraRTC.createClient({ mode: "rtc", codec: "vp8" }); await client.join( res.agora.appId, res.agora.channelName, res.agora.token, res.agora.uid, ); const mic = await AgoraRTC.createMicrophoneAudioTrack(); await client.publish([mic]); client.on("user-published", async (user, mediaType) => { await client.subscribe(user, mediaType); if (mediaType === "audio") user.audioTrack.play(); }); ``` **End to end — Server (Node)** ```javascript // Your server. The API key never reaches the browser. const ringing = new Map(); app.post("/pb-webhook", (req, res) => { const payload = req.body; switch (payload.event) { case "facetime.inbound.ringing": ringing.set(payload.call_uuid, payload); broadcast("incoming", payload); // your channel to the browser break; case "facetime.inbound.answered": ringing.delete(payload.call_uuid); broadcast("answered", payload); break; case "facetime.inbound.ended": ringing.delete(payload.call_uuid); broadcast("ended", payload); break; } res.sendStatus(200); }); async function proxyCall(path, callUuid, res) { const upstream = await fetch("https://api.tryprojectblue.com/" + path, { method: "POST", headers: { Authorization: `Bearer ${process.env.PROJECT_BLUE_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ call_uuid: callUuid }), }); const body = await upstream.json().catch(() => ({ error: "Empty upstream response" })); res.status(upstream.status).json(body); } app.post("/calls/:callUuid/answer", (req, res) => proxyCall("answer-facetime-call-api", req.params.callUuid, res), ); app.post("/calls/:callUuid/decline", (req, res) => proxyCall("decline-facetime-call-api", req.params.callUuid, res), ); ``` **End to end — Browser** ```javascript import AgoraRTC from "agora-rtc-sdk-ng"; let client; let mic; onEvent("incoming", ({ from, call_uuid }) => showRing({ from, call_uuid })); document.querySelector("#answer").onclick = async () => { const res = await fetch("/calls/" + currentCallUuid() + "/answer", { method: "POST" }); const body = await res.json(); if (!res.ok) { showError(body.error); return; } // 409 when someone else answered first if (body.agora == null) { showNoAudio(); return; } // answered, but no audio credentials client = AgoraRTC.createClient({ mode: "rtc", codec: "vp8" }); await client.join(body.agora.appId, body.agora.channelName, body.agora.token, body.agora.uid); mic = await AgoraRTC.createMicrophoneAudioTrack(); await client.publish([mic]); client.on("user-published", async (user, mediaType) => { await client.subscribe(user, mediaType); if (mediaType === "audio") user.audioTrack.play(); }); }; document.querySelector("#decline").onclick = async () => { await fetch("/calls/" + currentCallUuid() + "/decline", { method: "POST" }); }; onEvent("answered", () => hideRing()); onEvent("ended", async () => { hideRing(); if (client && mic) await client.unpublish([mic]); if (client) await client.leave(); }); ``` # Get lines Fetch all sending lines available to your account. Pass the returned `lineId` value to `/send-api-message` when you want to force a specific line. `GET /get-lines` **Request — cURL** ```bash curl -X GET https://api.tryprojectblue.com/get-lines \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Request — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/get-lines", { method: "GET", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}` } }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — cURL · Python** ```python import os import requests response = requests.request( "GET", "https://api.tryprojectblue.com/get-lines", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"] }, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200 OK** ```json [ { "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "devicePhoneNumber": "+15559876543", "customName": "Main Line" }, { "lineId": "9c2e4a1b-d3f8-4e1c-a2b4-c5d6e7f8a9b0", "devicePhoneNumber": "+15557654321", "customName": "Secondary Line" } ] ``` **Response — 401** ```json { "error": "Missing or invalid Authorization header" } ``` # Request lines Ask the Project Blue team for new lines in an area code. The request is queued for confirmation and does not return a line. When the request is saved, the 202 includes `lineRequestId` and `lineRequestStatus`. Once the lines are live they show up in `/get-lines`. `POST /request-line` ### Request body - `requestedAreaCode` (string, required) — Three-digit US or Canada area code for the new lines, e.g. "512". A number is also accepted. - `quantity` (integer (1–50), required) — How many lines to request in that area code. - `notes` (string) — Optional note for the Project Blue team, up to 1000 characters. Blank or omitted is stored as no note. Non-text values return 400. ### Response - `status` ("requested", required) — Present on every accepted request. - `requestedAreaCode` (string, required) — The area code that was requested, as a three-digit string. - `quantity` (integer, required) — How many lines were requested. - `lineRequestId` (string) — Id of the saved line request. Present when the request was written to the queue. Omitted if the save failed; the request still reaches the team. Repeating the same area code and quantity within two minutes returns this same id. - `lineRequestStatus` (string) — Status of the saved request. Currently awaiting_confirmation until the team confirms it. Omitted when lineRequestId is omitted. ### Status codes - **202** — Request sent to the Project Blue team - **400** — requestedAreaCode is not a 3-digit area code, quantity is not an integer from 1 to 50, or notes is not text or exceeds 1000 characters - **401** — Missing or invalid API key - **429** — Rate limit exceeded - **500** — Internal server error **Request — cURL** ```bash curl -X POST https://api.tryprojectblue.com/request-line \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "requestedAreaCode": "512", "quantity": 3, "notes": "Need these for a new office" }' ``` **Request — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/request-line", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "requestedAreaCode": "512", "quantity": 3, "notes": "Need these for a new office" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — cURL · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/request-line", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"requestedAreaCode": "512", "quantity": 3, "notes": "Need these for a new office"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 202 Accepted** ```json { "status": "requested", "requestedAreaCode": "512", "quantity": 3, "lineRequestId": "cmxyzrequestbatch001", "lineRequestStatus": "awaiting_confirmation" } ``` **Response — 400** ```json { "error": "requestedAreaCode must be a 3-digit US/Canada area code (e.g. "512")" } ``` # Check iMessage availability Check whether a phone number is reachable via iMessage before sending. Useful for routing logic or pre-qualifying contacts. `POST /api-check-imessage-availability` A `200` with `isIMessageAvailable: false` is now always a real answer. When the device lookup fails, the endpoint returns `503` with `retryable: true` instead of a false `200`. ### Request body - `phone` (string, required) — The phone number to check. Accepts many formats — we normalize to E.164. ### Status codes - **200** — Phone checked successfully - **400** — Invalid phone number format - **401** — Missing or invalid API key - **403** — Trial account probing a destination that is not verified on the shared line - **409** — Trial account has no shared line provisioned - **429** — Rate limit exceeded - **500** — Internal server error - **503** — iMessage availability check failed. Retryable device lookup failure: timeout, http_401, http_4xx, http_5xx, network, non_json or bb_error. **Request — cURL** ```bash curl -X POST https://api.tryprojectblue.com/api-check-imessage-availability \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "phone": "+15551234567" }' ``` **Request — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/api-check-imessage-availability", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "phone": "+15551234567" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — cURL · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/api-check-imessage-availability", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"phone": "+15551234567"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200 OK** ```json { "normalizedPhone": "+15551234567", "isIMessageAvailable": true } ``` **Response — 400** ```json { "error": "Invalid phone number format (Not a valid phone number). Please use format +12345678901" } ``` **Response — 409 — trial** Trial accounts only: the destination is verified but no shared line is provisioned. ```json { "error": "This trial account is not provisioned on a shared line" } ``` **Response — 503** Device lookup failed. failureKind is timeout, http_401, http_4xx, http_5xx, network, non_json, or bb_error. ```json { "error": "iMessage availability check failed", "failureKind": "timeout", "retryable": true } ``` # Create a contact External contacts are Project Blue's native contact store for accounts **without a connected CRM**. They render in the Project Blue app's contact list and details panel. `POST /create-external-contact` You can create them explicitly with the endpoints below, or implicitly by passing `firstName`, `lastName`, `email`, and `customFields` on `/send-api-message` — those fields persist on the auto-created contact for the recipient. > **For accounts without a connected CRM** > > If HighLevel or HubSpot is connected, contacts live in your CRM instead (see [CRM integration](https://api.tryprojectblue.com/docs/crm-integration)). External contacts apply to external/API-source accounts. Required: `phone` only (plus `Authorization: Bearer `). Optional: `firstName`, `lastName`, `email`, `customFields`. `customFields` is a JSON object of key/value pairs, max 10,000 characters when stringified. Omit it entirely if you have none. Same phone for the same API key is an upsert (fills blank names, overwrites email, shallow-merges `customFields`). > **Upserts do not behave like updates** > > When the phone number already exists this endpoint merges rather than replaces, and the rules differ per field:`firstName` and `lastName` are only filled in when the stored value is empty. Sending a new name for a contact that already has one is silently discarded.`email` overwrites whenever you send a non-empty value.`customFields` is **shallow-merged** here — the opposite of [update](https://api.tryprojectblue.com/docs/update-contact), which replaces the whole object. Sending `{}` changes nothing.The response is the contact as it was _before_ the merge, so a discarded name is not visible in it. Read the contact back if you need to confirm. The same merge runs when `/send-api-message` auto-creates a contact. ### Request body - `phone` (string, required) — The only required field besides Authorization. E.164 like +12345678901. - `firstName` (string) — The contact's first name. On upsert, filled in only when the stored value is blank. - `lastName` (string) — The contact's last name. On upsert, filled in only when the stored value is blank. - `email` (string) — The contact's email address. On upsert, overwrites the stored email. - `customFields` (object) — JSON object of key/value pairs. Max 10,000 characters when stringified. Omit it entirely if you have none. On upsert, shallow-merged into the stored object. ### The contact object All three endpoints return the same object. Create and update return it as `{ contact }`; list returns `{ contacts, pagination }`. There is no `status` envelope. - `id` (string, required) — Opaque contact id. Pass it back as contactId when updating; do not parse it. - `firstName` (string | null, required) — The contact's first name, or null if never set. - `lastName` (string | null, required) — The contact's last name, or null if never set. - `phoneNumber` (string, required) — The contact's number in E.164. Note the asymmetry: requests take phone, responses return phoneNumber. - `email` (string | null, required) — The contact's email address, or null if never set. - `customFields` (object | null, required) — Whatever JSON metadata you last stored. Replaced wholesale on update, never merged. - `note` (string | null, required) — Free-form note stored on the contact. - `createdAt` (string (ISO-8601), required) — When the contact was first created. - `updatedAt` (string (ISO-8601), required) — When the contact was last modified. **Request — Body** Required: phone only. Optional: firstName, lastName, email, customFields. ```javascript { "phone": "+15551234567", // required, E.164 like +12345678901 "firstName": "Jane", // optional "lastName": "Doe", // optional "email": "jane@example.com", // optional "customFields": { // optional object; omit if unused "shopifyCustomerId": "123", "shopifyOrderId": "456" } } ``` **Request — Minimal** Phone plus Authorization: Bearer is enough. ```json { "phone": "+15551234567" } ``` **Request — cURL** ```bash curl -X POST https://api.tryprojectblue.com/create-external-contact \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "phone": "+15551234567", "firstName": "Jane", "lastName": "Doe", "email": "jane@example.com", "customFields": { "shopifyCustomerId": "123", "shopifyOrderId": "456" } }' ``` **Request — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/create-external-contact", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "phone": "+15551234567", "firstName": "Jane", "lastName": "Doe", "email": "jane@example.com", "customFields": { "shopifyCustomerId": "123", "shopifyOrderId": "456" } }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — cURL · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/create-external-contact", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"phone": "+15551234567", "firstName": "Jane", "lastName": "Doe", "email": "jane@example.com", "customFields": {"shopifyCustomerId": "123", "shopifyOrderId": "456"}}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200** Wrapped as { contact }. List returns { contacts, pagination }. ```json { "contact": { "id": "string", "firstName": "string | null", "lastName": "string | null", "phoneNumber": "+15551234567", "email": "string | null", "customFields": { } | null, "note": "string | null", "createdAt": "ISO-8601", "updatedAt": "ISO-8601" } } ``` # List contacts Returns the authenticated user's external contacts, newest first, with pagination. Pass `phone` to look up a single contact by number. `GET /get-external-contacts` ### Query parameters - `limit` (integer (1–100)) — Maximum number of contacts to return. Defaults to 100. - `offset` (integer (≥ 0)) — Pagination offset. Defaults to 0. - `phone` (string) — Look up a single contact by phone number (exact match after normalization to E.164). **Request — cURL** ```bash curl -G https://api.tryprojectblue.com/get-external-contacts \ -H "Authorization: Bearer YOUR_API_KEY" \ --data-urlencode "limit=25" ``` **Request — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const url = new URL("https://api.tryprojectblue.com/get-external-contacts"); url.searchParams.append("limit", "25"); const response = await fetch(url, { method: "GET", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}` } }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — cURL · Python** ```python import os import requests response = requests.request( "GET", "https://api.tryprojectblue.com/get-external-contacts", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"] }, params=[("limit", "25")], timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200 OK** ```json { "contacts": [ { "id": "cmm4k2p1z0001s6ry9x8u7q3v", "firstName": "Jamie", "lastName": "Rivera", "phoneNumber": "+15551234567", "email": "jamie@example.com", "customFields": { "orderId": "ord_18342", "plan": "pro" }, "note": null, "createdAt": "2026-08-14T17:22:05.118Z", "updatedAt": "2026-08-14T17:22:05.118Z" } ], "pagination": { "limit": 25, "offset": 0, "total": 138 } } ``` # Update a contact Updates an existing contact's name, email, note, or custom metadata. The contact's phone number cannot be changed. Returns 404 if the contact does not belong to your account. `POST /update-external-contact` At least one of `firstName`, `lastName`, `email`, `customFields`, or `note` must be present. A request carrying only `contactId` returns 400. The phone number cannot be changed. ### Request body - `contactId` (string, required) — The contact id, as returned by the create or list endpoints. - `firstName` (string) — New first name for the contact. - `lastName` (string) — New last name for the contact. - `email` (string) — New email address for the contact. - `note` (string) — Free-form note stored on the contact. - `customFields` (object) — Replaces the entire stored customFields object — fetch the current contact and merge client-side to preserve existing keys. Plain object only; max 10,000 characters when JSON-serialized. > **How customFields is validated** > > Three distinct `400` bodies come out of the same check, on every endpoint that accepts `customFields`: `customFields must be a JSON object of key/value pairs` when the value is not a plain object, `customFields must be a JSON-serializable object` when it contains something that cannot be stringified, and `customFields JSON exceeds maximum length of 10000 characters` past the size cap. That cap counts characters of serialized JSON, not bytes — non-ASCII values reach it later than their byte size suggests. > **customFields is replaced, not merged** > > Sending `customFields` on an update overwrites the entire stored object. To add or change one key, fetch the contact first, merge on your side, and send the full object back. **Request — cURL** ```bash curl -X POST https://api.tryprojectblue.com/update-external-contact \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contactId": "cmm4k2p1z0001s6ry9x8u7q3v", "note": "VIP customer — prefers texts over calls", "customFields": { "orderId": "ord_18342", "plan": "enterprise" } }' ``` **Request — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/update-external-contact", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "contactId": "cmm4k2p1z0001s6ry9x8u7q3v", "note": "VIP customer — prefers texts over calls", "customFields": { "orderId": "ord_18342", "plan": "enterprise" } }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — cURL · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/update-external-contact", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"contactId": "cmm4k2p1z0001s6ry9x8u7q3v", "note": "VIP customer — prefers texts over calls", "customFields": {"orderId": "ord_18342", "plan": "enterprise"}}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200 OK** ```json { "contact": { "id": "cmm4k2p1z0001s6ry9x8u7q3v", "firstName": "Jamie", "lastName": "Rivera", "phoneNumber": "+15551234567", "email": "jamie@example.com", "customFields": { "orderId": "ord_18342", "plan": "enterprise" }, "note": "VIP customer — prefers texts over calls", "createdAt": "2026-08-14T17:22:05.118Z", "updatedAt": "2026-08-16T09:03:41.760Z" } } ``` **Response — 404** ```json { "error": "Contact not found" } ``` **Response — 400 — no fields** ```json { "error": "At least one updatable field is required (firstName, lastName, email, customFields, note). phoneNumber cannot be updated." } ``` **Response — 400 — customFields** ```json { "error": "customFields JSON exceeds maximum length of 10000 characters" } ``` # Set a contact card A contact card is the name and photo recipients see at the top of a conversation with one of your lines — the iMessage “Share Name and Photo” identity. These endpoints create it, read back what the line actually holds, and share it into a conversation, so a new line can be branded without anyone touching the Mac. `POST /set-contact-card` > **The usual sequence** > > **Create** — `POST /set-contact-card` with name and photo. Read `status`.**Verify** — `GET /get-contact-card`. The line reports its live name and photo; `line.state` should be `APPLIED`.**Share** — `POST /share-contact-card` to a destination you have already messaged.**Update** — `POST /set-contact-card` again with only the fields that change; the rest stays.**Reshare** — share again. A fresh card revision is never collapsed as a duplicate. Creates the line's card on the first call and updates it on later ones. Omitted fields keep their current value, so a name-only update leaves the photo alone. The photo is fetched (or decoded), centre-cropped to a 256 px square JPEG, stored, and pushed to the line in one request. Expect a few seconds; the line has to persist the card through Messages before it answers. ### Request body - `lineId` (string (UUID v4), required) — The line whose iMessage name and photo to set. Use a lineId returned from GET /get-lines. - `firstName` (string) — First name shown in the recipient's Messages header. 1–64 characters. Required when the line has no contact card yet; omitted on a later call keeps the current value. - `lastName` (string) — Last name shown next to firstName. Same rules as firstName. Many customers put the business name here. - `imageUrl` (string (https URL) | null) — Public https URL of the photo. JPEG, PNG, WebP, GIF or HEIC up to 10 MB; it is centre-cropped to a 256 px square JPEG before it reaches the line. Pass null to remove the photo. Omit to keep the current one. Private and internal hosts are rejected. - `imageBase64` (string) — The photo as base64 (a data: URL is accepted). Same formats and cap as imageUrl. Mutually exclusive with imageUrl. > **Read status, not the HTTP code** > > The line reports the name and the photo separately, and the response passes that through rather than rounding it up to success:`APPLIED` (200) — the line confirmed everything you sent.`PARTIAL` (200, `error_code: PHOTO_NOT_APPLIED`) — the name landed but the photo did not. The stored card keeps its previous photo. Retry with a different image.`FAILED` (4xx / 502) — nothing changed. `error_code` says why; see the table below.`INDETERMINATE` (504, `error_code: DEVICE_TIMEOUT`) — the line did not answer in time. The card may or may not have applied. Call `GET /get-contact-card`; do not assume either way. ### The contactCard object - `cardId` (string, required) — Opaque id of the stored card. Do not parse it. - `firstName` (string, required) — Stored first name. - `lastName` (string, required) — Stored last name. - `imageUrl` (string | null, required) — Public URL of the normalised photo Project Blue stored, or null when the card has no photo. - `hasPhoto` (boolean, required) — Whether the stored card carries a photo. - `appliedToLine` (boolean, required) — True once the line confirmed this exact card. False after a PARTIAL or INDETERMINATE set, or when GET /get-contact-card found the line showing something else. - `updatedAt` (string (ISO-8601), required) — When the stored card last changed. ### Status codes - **200** — APPLIED or PARTIAL — see status. - **400** — Bad input (`CONTACT_CARD_NAME_REQUIRED` on a first call without both names; `IMAGE_INVALID`, `IMAGE_TOO_LARGE`, `IMAGE_FETCH_FAILED`, `IMAGE_URL_NOT_ALLOWED` for the photo). - **401** — Missing or invalid API key. - **403** — Trial account, or `LINE_NOT_ELIGIBLE` — an SMS-only or shared line has no iMessage identity to set. - **409** — The line cannot take the change yet: `LINE_UNSUPPORTED_SERVER` (needs BlueBubbles 2.2.0+), `LINE_PRIVATE_API_DISABLED`, `LINE_HELPER_DISCONNECTED`, `LINE_NOT_REGISTERED_IMESSAGE`, or `LINE_NOT_PROVISIONED`. Contact support. - **429** — Rate limit exceeded. - **502** — `DEVICE_REJECTED` — the line refused the card; or `IMAGE_STORAGE_FAILED` before anything reached the line. - **503** — `LINE_OFFLINE` — the line did not answer the readiness check. Nothing changed; retry shortly. - **504** — INDETERMINATE — read the card back. > **Idempotency** > > An identical request (same line, names and image) within a short window is collapsed and the first result replayed with `deduped: true`. Pass an `Idempotency-Key` header to control this yourself. An `INDETERMINATE` result is never cached, so a retry after a timeout does run again — the line applies the same card twice harmlessly. **Request — Create** ```bash curl -X POST https://api.tryprojectblue.com/set-contact-card \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "firstName": "Jamie", "lastName": "Rivera Realty", "imageUrl": "https://example.com/brand/jamie-512.png" }' ``` **Request — Create · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/set-contact-card", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "firstName": "Jamie", "lastName": "Rivera Realty", "imageUrl": "https://example.com/brand/jamie-512.png" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — Create · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/set-contact-card", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "firstName": "Jamie", "lastName": "Rivera Realty", "imageUrl": "https://example.com/brand/jamie-512.png"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Request — Update name** ```bash curl -X POST https://api.tryprojectblue.com/set-contact-card \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "lastName": "Rivera Group" }' ``` **Request — Update name · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/set-contact-card", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "lastName": "Rivera Group" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — Update name · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/set-contact-card", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "lastName": "Rivera Group"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Request — Remove photo** ```bash curl -X POST https://api.tryprojectblue.com/set-contact-card \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "imageUrl": null }' ``` **Request — Remove photo · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/set-contact-card", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "imageUrl": null }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — Remove photo · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/set-contact-card", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "imageUrl": None}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200 APPLIED** ```json { "status": "APPLIED", "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "contactCard": { "cardId": "cmm7p3x9a0001s6ryh2k4d8nq", "firstName": "Jamie", "lastName": "Rivera Realty", "imageUrl": "https://…/contact-poster-images/api/user-42/line-84/3f9c…e1.jpg", "hasPhoto": true, "appliedToLine": true, "updatedAt": "2026-10-13T17:04:12.118Z" }, "line": { "readiness": "READY", "serverVersion": "2.2.0", "nameApplied": true, "photoApplied": true }, "error_code": null, "error_message": null } ``` **Response — 200 PARTIAL** ```json { "status": "PARTIAL", "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "contactCard": { "cardId": "cmm7p3x9a0001s6ryh2k4d8nq", "firstName": "Jamie", "lastName": "Rivera Realty", "imageUrl": null, "hasPhoto": false, "appliedToLine": false, "updatedAt": "2026-10-13T17:04:12.118Z" }, "line": { "readiness": "READY", "serverVersion": "2.2.0", "nameApplied": true, "photoApplied": false }, "error_code": "PHOTO_NOT_APPLIED", "error_message": "Contact card name updated, but avatar could not be applied." } ``` **Response — 504 INDETERMINATE** ```json { "status": "INDETERMINATE", "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "contactCard": { "cardId": "cmm7p3x9a0001s6ryh2k4d8nq", "firstName": "Jamie", "lastName": "Rivera Realty", "imageUrl": "https://…/contact-poster-images/api/user-42/line-84/3f9c…e1.jpg", "hasPhoto": true, "appliedToLine": false, "updatedAt": "2026-10-13T17:04:12.118Z" }, "line": { "readiness": "READY", "serverVersion": "2.2.0", "nameApplied": null, "photoApplied": null }, "error_code": "DEVICE_TIMEOUT", "error_message": "The line did not answer within 30s. Call GET /get-contact-card to see what applied; do not assume it did." } ``` **Response — 409 — old server** ```json { "status": "FAILED", "error_code": "LINE_UNSUPPORTED_SERVER", "error_message": "This line runs BlueBubbles 2.1.2; contact cards need 2.2.0 or newer. Contact support to upgrade the line." } ``` # Get a contact card Returns the card Project Blue stored for the line and, read live, what Messages on the line currently holds. This is the source of truth after an `INDETERMINATE` set and the way to notice a card someone changed on the Mac by hand. `GET /get-contact-card` ### Query parameters - `lineId` (string (UUID v4), required) — The line to read. Use a lineId returned from GET /get-lines. ### The line object - `readiness` ("READY" | "OFFLINE" | "UNSUPPORTED_SERVER" | "PRIVATE_API_DISABLED" | "HELPER_DISCONNECTED" | "NOT_REGISTERED" | "LINE_NOT_ELIGIBLE", required) — Whether the line can take contact-card calls right now, checked live on every request. Anything other than READY also appears as an error_code on the write endpoints. - `serverVersion` (string | null, required) — BlueBubbles version the line is running. Contact cards need 2.2.0 or newer. - `name` (string | null, required) — The name Messages on the line currently holds, read live. null when the line could not be read. - `hasPhoto` (boolean | null, required) — Whether Messages on the line currently holds a photo. - `state` ("APPLIED" | "MISMATCH" | "NOT_SET" | "UNMANAGED" | "UNAVAILABLE", required) — How the live card compares with the stored one. APPLIED matches; MISMATCH means someone changed it on the Mac or a set did not finish; NOT_SET has no card anywhere; UNMANAGED has a card on the Mac that was never set through Project Blue; UNAVAILABLE means the line could not be read. When the live card matches the stored one, `appliedToLine` on the stored card is set to `true`; when it does not, it is cleared. Reading is always 200 — a line that cannot be reached reports `state: UNAVAILABLE` with the readiness reason rather than an error. **Request — cURL** ```bash curl -G https://api.tryprojectblue.com/get-contact-card \ -H "Authorization: Bearer YOUR_API_KEY" \ --data-urlencode "lineId=a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5" ``` **Request — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const url = new URL("https://api.tryprojectblue.com/get-contact-card"); url.searchParams.append("lineId", "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5"); const response = await fetch(url, { method: "GET", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}` } }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — cURL · Python** ```python import os import requests response = requests.request( "GET", "https://api.tryprojectblue.com/get-contact-card", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"] }, params=[("lineId", "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5")], timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200 OK** ```json { "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "contactCard": { "cardId": "cmm7p3x9a0001s6ryh2k4d8nq", "firstName": "Jamie", "lastName": "Rivera Realty", "imageUrl": "https://…/contact-poster-images/api/user-42/line-84/3f9c…e1.jpg", "hasPhoto": true, "appliedToLine": true, "updatedAt": "2026-10-13T17:04:12.118Z" }, "line": { "readiness": "READY", "serverVersion": "2.2.0", "name": "Jamie Rivera Realty", "hasPhoto": true, "state": "APPLIED" } } ``` **Response — 200 — line not ready** ```json { "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "contactCard": null, "line": { "readiness": "UNSUPPORTED_SERVER", "serverVersion": "2.1.2", "name": null, "hasPhoto": null, "state": "UNAVAILABLE" } } ``` # Share a contact card Sends the line's saved name and photo into an existing 1:1 conversation, so Messages on the recipient's side offers to update the contact. Apple decides when the recipient sees it; it usually appears with the next message in that thread. `POST /share-contact-card` ### Request body - `lineId` (string (UUID v4), required) — The line whose card to share. The line must already have a card from POST /set-contact-card. - `destination` (string, required) — The recipient — a phone number (any common format, normalised to E.164) or an iMessage email address. An iMessage conversation between the line and this destination must already exist; send a message first if it does not. > **The conversation must already exist** > > Sharing goes into a chat, not to a number. If the line has never exchanged a message with the destination you get `404 CHAT_NOT_FOUND`. Send one message with `/send-api-message` first, then share. > **SHARED means the line accepted it** > > `confirmation: LINE_ACCEPTED` is exactly that — Messages on the line took the send. The API cannot see whether the recipient's device displayed the card, so there is no “delivered” state and none is implied. ### Status codes - **200** — SHARED — the line accepted the send. - **400** — Bad lineId or destination. - **401** — Missing or invalid API key. - **403** — Trial account, or `LINE_NOT_ELIGIBLE`. - **404** — `CHAT_NOT_FOUND` — no conversation with the destination on this line. - **409** — `NO_CONTACT_CARD` — set one first; or the line is not ready (same codes as set). - **429** — Rate limit exceeded. - **502** — `SHARE_REJECTED` — the line refused the share. - **503** — `LINE_OFFLINE` — nothing was shared; retry shortly. - **504** — `SHARE_TIMEOUT` — INDETERMINATE; the card may have gone out. > **Idempotency and resharing** > > The same line, destination and card revision within a short window is one share; a repeat replays the first result with `deduped: true`. Updating the card changes its revision, so share-after-update always sends. An `INDETERMINATE` result _is_ cached, so a blind retry after a timeout does not send a second card — pass a new `Idempotency-Key` once the recipient confirms nothing arrived. **Request — Share** ```bash curl -X POST https://api.tryprojectblue.com/share-contact-card \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "destination": "+15551234567" }' ``` **Request — Share · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/share-contact-card", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "destination": "+15551234567" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — Share · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/share-contact-card", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "destination": "+15551234567"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Request — Reshare** ```bash curl -X POST https://api.tryprojectblue.com/share-contact-card \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: reshare-2026-10-13-rivera-group" \ -d '{ "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "destination": "+15551234567" }' ``` **Request — Reshare · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/share-contact-card", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "reshare-2026-10-13-rivera-group" }, body: JSON.stringify({ "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "destination": "+15551234567" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — Reshare · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/share-contact-card", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json", "Idempotency-Key": "reshare-2026-10-13-rivera-group" }, json={"lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "destination": "+15551234567"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200 SHARED** ```json { "status": "SHARED", "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "destination": "+15551234567", "chatGuid": "iMessage;-;+15551234567", "confirmation": "LINE_ACCEPTED", "contactCard": { "cardId": "cmm7p3x9a0001s6ryh2k4d8nq", "firstName": "Jamie", "lastName": "Rivera Realty", "imageUrl": "https://…/contact-poster-images/api/user-42/line-84/3f9c…e1.jpg", "hasPhoto": true, "appliedToLine": true, "updatedAt": "2026-10-13T17:04:12.118Z" }, "line": { "readiness": "READY", "serverVersion": "2.2.0" }, "note": "The line accepted the share. Apple controls when the recipient sees the name and photo; it usually appears on the next message in that conversation.", "error_code": null, "error_message": null } ``` **Response — 404 — no chat** ```json { "status": "FAILED", "error_code": "CHAT_NOT_FOUND", "error_message": "No iMessage conversation with +15551234567 exists on this line. Send a message to the destination first, then share.", "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "destination": "+15551234567" } ``` **Response — 409 — no card** ```json { "status": "FAILED", "error_code": "NO_CONTACT_CARD", "error_message": "This line has no contact card. Set one with POST /set-contact-card first." } ``` **Response — 504 INDETERMINATE** ```json { "status": "INDETERMINATE", "lineId": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "destination": "+15551234567", "chatGuid": "iMessage;-;+15551234567", "error_code": "SHARE_TIMEOUT", "error_message": "The line did not confirm the share within 15s. The card may still have been sent; do not assume either way. Retry with a new Idempotency-Key only if the recipient confirms they did not receive it." } ``` # List flows Workflows are automation flows built in the Project Blue app — send a message, wait, branch on a reply, and so on. These endpoints list your published flows, enroll a contact or group (which starts the run immediately), and cancel active runs for a contact or group. `GET /get-flows` > **Enrollment runs immediately** > > Only Published flows can be enrolled. Enrolling a contact executes the first step right away — real messages may be sent. When `pb_line_id` is omitted, a line is selected automatically at enrollment and pinned for the entire run; the chosen line is returned in the response. Returns the authenticated user's published Workflows. Use each flow's `id` as `flowId` when enrolling a contact. Ids are opaque UUID strings, not sequential numbers — pass them back verbatim. **Request — cURL** ```bash curl -X GET https://api.tryprojectblue.com/get-flows \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Request — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/get-flows", { method: "GET", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}` } }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — cURL · Python** ```python import os import requests response = requests.request( "GET", "https://api.tryprojectblue.com/get-flows", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"] }, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200 OK** ```json { "flows": [ { "id": "6f1c2a7e-9d4b-4c31-8a52-1e7f0b3d9c84", "name": "New Lead Follow-up" }, { "id": "b28d5f30-71ac-4e69-9f13-52c6ad8071be", "name": "Appointment Reminder" } ] } ``` # Enroll a contact Starts a Workflow run for the given contact or group. The first step executes immediately. The response includes `runId` and the `pb_line_id` pinned to the run, plus `groupId` when enrolled by group. `POST /enroll-flow` Because the first step runs before the response is written, the returned `status` is the state _after_ that step. A run that begins with a wait comes back `SLEEPING`, and one that begins by asking a question comes back `WAITING_REPLY` — `ACTIVE` is the exception, not the rule. Statuses are uppercase: `ACTIVE`, `SLEEPING`, `WAITING_REPLY`, `COMPLETED`, `CANCELLED`, `FAILED`. ### Request body - `flowId` (string (UUID), required) — The Workflow id, as returned by GET /get-flows. An opaque UUID string — do not parse it. Must be 1 to 64 characters. - `phoneNumber` (string) — The contact's phone number. Accepts many formats — normalized to E.164. Exactly one of phoneNumber or groupId is required. - `groupId` (string) — The groupId returned by POST /send-group-message (pbg_…). Exactly one of phoneNumber or groupId is required. A group run sends into the group from the line it lives on. - `pb_line_id` (string (UUID)) — Optional. Line to send from (lineId from GET /get-lines). When omitted, a line is selected automatically and pinned for the entire run. - `variables` (object) — Optional string values for this run. first_name, last_name, email, and company override the matching core tokens. Every other key is available as {{custom.}}. first_name and last_name create the Project Blue contact only when no CRM is connected. CRM accounts never get a Project Blue contact from enrollment. Keys are letters, digits, and underscores; case insensitive; max 50 keys; max 500 characters per value. Example: {"first_name":"Jane","order_id":"123"}. > **Personalization** > > Workflow messages can include `{{first_name}}`, `{{last_name}}`, `{{email}}`, `{{company}}`, `{{phone}}`, `{{reply}}` (the contact's last reply during a wait step), and `{{custom.}}`. An optional fallback is written as `{{first_name|there}}`. Unknown tokens with no fallback render as an empty string. At send time each token is filled in this order: 1. `variables` sent on the enroll request 2. the connected CRM contact (HighLevel, HubSpot, or Close), looked up live by the contact's phone number 3. the Project Blue contact record, only for accounts with no connected CRM `{{custom.}}` reads from `variables` first, then from the CRM using the CRM's own field identifier. HighLevel uses the custom field key without the `contact.` prefix (the part GHL shows in `{{contact.}}`). HubSpot uses the contact property internal name. Close uses the custom field name, case insensitive, on the contact or its lead. Accounts with no CRM get custom values from `variables` only. ### Status codes - **400** — Provide phoneNumber or groupId, not both; phoneNumber or groupId is required; This group lives on a different line; pb_line_id is required for this group; invalid phone number, invalid pb_line_id, or no available lines - **403** — Contact has opted out - **404** — Group not found for this account; flow not found or not published, or line not found - **409** — This group's line is no longer on this account; an active run already exists for this contact in this flow **Request — cURL** ```bash curl -X POST https://api.tryprojectblue.com/enroll-flow \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "flowId": "6f1c2a7e-9d4b-4c31-8a52-1e7f0b3d9c84", "phoneNumber": "+16025551234", "pb_line_id": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "variables": { "first_name": "Jane", "order_id": "123" } }' ``` **Request — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/enroll-flow", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "flowId": "6f1c2a7e-9d4b-4c31-8a52-1e7f0b3d9c84", "phoneNumber": "+16025551234", "pb_line_id": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "variables": { "first_name": "Jane", "order_id": "123" } }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — cURL · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/enroll-flow", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"flowId": "6f1c2a7e-9d4b-4c31-8a52-1e7f0b3d9c84", "phoneNumber": "+16025551234", "pb_line_id": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "variables": {"first_name": "Jane", "order_id": "123"}}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Request — Group** ```bash curl -X POST https://api.tryprojectblue.com/enroll-flow \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "flowId": "6f1c2a7e-9d4b-4c31-8a52-1e7f0b3d9c84", "groupId": "pbg_..." }' ``` **Request — Group · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/enroll-flow", { method: "POST", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "flowId": "6f1c2a7e-9d4b-4c31-8a52-1e7f0b3d9c84", "groupId": "pbg_..." }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — Group · Python** ```python import os import requests response = requests.request( "POST", "https://api.tryprojectblue.com/enroll-flow", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"flowId": "6f1c2a7e-9d4b-4c31-8a52-1e7f0b3d9c84", "groupId": "pbg_..."}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200 OK** ```json { "success": true, "runId": 4182, "status": "SLEEPING", "currentNodeId": "node_wait_1", "pb_line_id": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5" } ``` **Response — 200 group** groupId is present when the run was enrolled by group. ```json { "success": true, "runId": 4182, "status": "SLEEPING", "currentNodeId": "node_wait_1", "pb_line_id": "a3f8c2d1-b4e9-4f2a-c8d3-e1f0a2b3c4d5", "groupId": "pbg_..." } ``` **Response — 400** ```json { "error": "Invalid flowId" } ``` **Response — 403** ```json { "error": "Contact is opted out / blocked" } ``` **Response — 404** ```json { "error": "Flow not found or not published" } ``` **Response — 409** ```json { "error": "An active run already exists for this contact in this flow" } ``` # Cancel flow runs Cancels all active Workflow runs for the given contact or group. Safe to call when there are no active runs. `POST` is accepted as an alias for clients that cannot send `DELETE` with a body. `DELETE POST /cancel-flow-runs` ### Request body - `phoneNumber` (string) — The contact's phone number. Cancels all of this contact's active Workflow runs. Accepts many formats — normalized to E.164. Exactly one of phoneNumber or groupId is required. - `groupId` (string) — The groupId returned by POST /send-group-message (pbg_…). Exactly one of phoneNumber or groupId is required. Cancels all active Workflow runs for that group. ### Status codes - **400** — Provide phoneNumber or groupId, not both; phoneNumber or groupId is required - **404** — Group not found for this account **Request — cURL** ```bash curl -X DELETE https://api.tryprojectblue.com/cancel-flow-runs \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "phoneNumber": "+16025551234" }' ``` **Request — cURL · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/cancel-flow-runs", { method: "DELETE", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "phoneNumber": "+16025551234" }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — cURL · Python** ```python import os import requests response = requests.request( "DELETE", "https://api.tryprojectblue.com/cancel-flow-runs", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"phoneNumber": "+16025551234"}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Request — Group** ```bash curl -X DELETE https://api.tryprojectblue.com/cancel-flow-runs \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "groupId": "pbg_..." }' ``` **Request — Group · JavaScript** ```javascript // Run on your server. Keep your API key private. const response = await fetch("https://api.tryprojectblue.com/cancel-flow-runs", { method: "DELETE", headers: { "Authorization": `Bearer ${process.env.PB_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ "groupId": "pbg_..." }) }); const data = await response.json(); if (!response.ok) throw new Error(JSON.stringify(data)); console.log(data); ``` **Request — Group · Python** ```python import os import requests response = requests.request( "DELETE", "https://api.tryprojectblue.com/cancel-flow-runs", headers={ "Authorization": "Bearer " + os.environ["PB_API_KEY"], "Content-Type": "application/json" }, json={"groupId": "pbg_..."}, timeout=30, ) response.raise_for_status() print(response.json()) ``` **Response — 200 OK** ```json { "success": true, "cancelled": 1 } ``` # MCP server & skill Working with an AI assistant? Connect it here first — this is the fastest way to send a message, and there is no API key to paste. The Project Blue MCP server gives Claude Desktop, Claude Code, Cursor, and any other MCP-compatible client the ability to send iMessage and SMS, place FaceTime Audio calls, manage contacts, run Workflows, and read message and call history — directly from the editor or chat surface. Authentication is OAuth 2.1 in the browser. Writing code against the REST API instead? Start with the [Quickstart](https://api.tryprojectblue.com/docs/quickstart). ### Server URL ## Two ways to connect **Add the server directly.** This is the standard path and works in any MCP client — paste the URL, or run the one-liner in the rail. Nothing else is installed. **Or install the plugin** (Claude Code only). It registers the same server and adds a Project Blue skill carrying the workflow rules the tool descriptions cannot: the trial verification sequence, when a retry is being deduplicated rather than failing, the FaceTime call lifecycle, and which contact endpoint merges versus replaces. > **Neither path supersedes the other** > > Both connect to the same server with the same tools and the same OAuth flow. `claude plugin install` is a convenience, not a requirement — if you already added the server with `claude mcp add`, it keeps working and there is nothing to migrate. Installing both would simply register the server twice, so pick one. ## Set up your client Pick your client in the rail and run the snippet. Every one of them ends the same way: your client opens a browser to **app.tryprojectblue.com**, you approve the connection, and it is done. OAuth 2.1 with dynamic client registration — no key to paste, no tokens to rotate. | Client | Where it goes | | --- | --- | | Claude Code | `claude mcp add`, or install the plugin below | | Codex | `codex mcp add` then `codex mcp login`, or `~/.codex/config.toml` | | Cursor | `~/.cursor/mcp.json` or `.cursor/mcp.json` | | VS Code | `.vscode/mcp.json` | | Claude Desktop | Settings → Connectors → Add custom connector, then paste the server URL | Any other client that speaks remote MCP over streamable HTTP works with the server URL alone. For one that only accepts stdio servers, use `mcp-remote` as an adapter — both are in the rail. ## Available tools | Tool | Type | Description | | --- | --- | --- | | `send_message` | write | Send an iMessage or SMS to a single recipient. Supports media, audio, AI voice memo, an optional lineId override, and an optional iMessage-only send effect. | | `send_typing_indicator` | write | Show the iMessage typing indicator. iMessage-only; requires an existing conversation. Pattern: typing → brief delay → send_message. Fire-and-forget — do not retry on ERROR. | | `send_reaction` | write | React to a message with an iMessage tapback (love, like, dislike, laugh, emphasize, question). Pass messageHandle from list_messages. remove:true retracts the same type. | | `send_group_message` | write | Send an iMessage or SMS to a group of 2–32 recipients. Queued (status always queued, service always null). Same numbers reuse the thread. No CRM sync. Unavailable on trial accounts — see Trial Accounts. | | `lookup_imessage_availability` | read | Check whether a phone number supports iMessage. A 200 false is always a real answer; a failed lookup returns 503 with retryable true. | | `get_lines` | read | List the user's Project Blue sending lines (lineId, devicePhoneNumber, customName). | | `request_line` | write | Ask the Project Blue team for 1–50 new lines in a US/Canada area code, with an optional note. Lines are provisioned by the team, not returned immediately. The response includes lineRequestId and lineRequestStatus when the request was saved. | | `list_messages` | read | List recent inbound/outbound messages with filters (service, direction, line, date ranges). | | `get_message` | read | Fetch a single message by its opaque message_handle. | | `get_call_logs` | read | List the user's outbound dialer call logs with filters for line and answered_at range. Includes call status, disposition, transcript, and recording URL when available. | | `start_facetime_call` | write | Place a FaceTime Audio call from a FaceTime-enabled line. Returns call_uuid plus Agora WebRTC credentials the caller must use to join the call audio. Requires FaceTime Audio on the account. | | `get_facetime_call_status` | read | Poll a FaceTime call's live status (initiated, ringing, answered, ended, declined, no_answer, failed) by call_uuid. | | `end_facetime_call` | write | Hang up an in-progress FaceTime call by call_uuid. | | `create_external_contact` | write | Create (or upsert by phone number) an external contact with name, email, and custom JSON metadata. For accounts without a connected CRM. | | `get_external_contacts` | read | List the user's external contacts (newest first) with pagination, or look one up by phone number. | | `update_external_contact` | write | Update an external contact's name, email, note, or customFields by contact id. customFields is replaced wholesale, not merged. | | `list_flows` | read | List the user's published Workflows (id and name). Use the id as flowId with enroll_contact_in_flow. | | `enroll_contact_in_flow` | write | Enroll a contact or group in a published Workflow. Starts the run immediately and may send real messages. Pass phoneNumber or groupId. Returns runId, the pinned pb_line_id, and groupId when enrolled by group. | | `cancel_flow_runs` | write | Cancel all active Workflow runs for a contact or group. Pass phoneNumber or groupId. Safe when there are no active runs. | **Connect — Claude Code** Opens a browser to complete OAuth on first use. ```bash claude mcp add --transport http project-blue \ https://api.tryprojectblue.com/api/mcp ``` **Connect — Codex** Add the server, then authenticate. Codex picks HTTP transport from --url. ```bash codex mcp add project-blue \ --url https://api.tryprojectblue.com/api/mcp codex mcp login project-blue ``` **Connect — Cursor** ~/.cursor/mcp.json (global) or .cursor/mcp.json (per-project). ```json { "mcpServers": { "project-blue": { "url": "https://api.tryprojectblue.com/api/mcp" } } } ``` **Connect — VS Code** .vscode/mcp.json in the workspace. ```json { "servers": { "project-blue": { "type": "http", "url": "https://api.tryprojectblue.com/api/mcp" } } } ``` **Connect — Codex (TOML)** ~/.codex/config.toml, if you prefer editing config directly. ```toml [mcp_servers.project-blue] url = "https://api.tryprojectblue.com/api/mcp" auth = "oauth" ``` **Connect — Any client** Paste this URL into any MCP client's connector settings. ``` https://api.tryprojectblue.com/api/mcp ``` **Connect — mcp-remote** Adapter for clients that only accept stdio servers. ```json { "mcpServers": { "project-blue": { "command": "npx", "args": ["-y", "mcp-remote", "https://api.tryprojectblue.com/api/mcp"] } } } ``` **Plugin — Claude Code** Optional: same server, plus the Project Blue skill. ```bash claude plugin marketplace add try-pb/pb-api claude plugin install project-blue@project-blue ```