### Install and Setup Sendblue CLI Source: https://docs.sendblue.com/getting-started/quickstart Install the Sendblue CLI globally and run the setup command to create an account, get API keys, and save credentials. ```bash npm install -g @sendblue/cli sendblue setup ``` -------------------------------- ### Setup Sendblue Account with CLI Source: https://docs.sendblue.com/getting-started Initiate the Sendblue account setup process using the CLI. This command guides through account creation and number assignment. ```bash sendblue setup ``` -------------------------------- ### Install and Setup Sendblue CLI Source: https://docs.sendblue.com/llms.txt Install the Sendblue CLI globally and set up your account using a phone number. You will need to text a one-time phrase from the specified phone number to verify. ```bash npm install -g @sendblue/cli sendblue setup --phone +15551234567 --company my-agent ``` -------------------------------- ### Install Sendblue CLI Source: https://docs.sendblue.com/getting-started Install the Sendblue Command Line Interface globally. This is the first step for most setup procedures. ```bash npm install -g @sendblue/cli ``` -------------------------------- ### Example: Get Message Source: https://docs.sendblue.com/api-v2/messages This example shows how to retrieve a specific message using its ID. ```bash curl "https://api.sendblue.com/api/v2/messages/5a17319e-cbcf-443e-897e-d8b0c04b1b09" \ -H "sb-api-key-id: YOUR_API_KEY" \ -H "sb-api-secret-key: YOUR_API_SECRET" ``` -------------------------------- ### Sendblue CLI Setup without Global Install Source: https://docs.sendblue.com/llms.txt Execute the Sendblue CLI setup command directly using npx without a global installation. This is a preferred method for quick usage. ```bash npx -y @sendblue/cli setup --phone +15551234567 --company account-name ``` -------------------------------- ### Start FaceTime Call Request Example (cURL) Source: https://docs.sendblue.com/calling/facetime Example cURL request to start a FaceTime call. Replace placeholders with your API keys and desired phone numbers. ```curl curl -X POST 'https://api.sendblue.com/facetime/start-call' \ -H 'sb-api-key-id: YOUR_API_KEY' \ -H 'sb-api-secret-key: YOUR_API_SECRET' \ -H 'Content-Type: application/json' \ -d '{ "phoneNumber": "+14155550123", "fromNumber": "+18885550199" }' ``` -------------------------------- ### Install Sendblue API Library Source: https://docs.sendblue.com/api/typescript Install the Sendblue API library using npm. ```bash npm install sendblue ``` -------------------------------- ### Example: List Messages with Filters Source: https://docs.sendblue.com/api-v2/messages This example demonstrates how to list messages using query parameters for service type, outbound status, and limit. ```bash curl "https://api.sendblue.com/api/v2/messages?service=iMessage&is_outbound=true&limit=50" \ -H "sb-api-key-id: YOUR_API_KEY" \ -H "sb-api-secret-key: YOUR_API_SECRET" ``` -------------------------------- ### Install openclaw-sendblue Plugin Requirements Source: https://docs.sendblue.com/getting-started Install the Sendblue CLI and set up your Sendblue account. This is a prerequisite for installing the openclaw-sendblue plugin. ```bash npm install -g @sendblue/cli sendblue setup sendblue show-keys ``` -------------------------------- ### Install MCP Server Source: https://docs.sendblue.com/llms.txt Install the MCP server for AI editor and agent integration with Sendblue. Authentication is handled via environment variables. ```bash npx -y sendblue-api-mcp@latest ``` -------------------------------- ### Start TextMe AI Chatbot Source: https://docs.sendblue.com/getting-started/quickstart Start the TextMe AI chatbot application after configuration. ```bash npm start ``` -------------------------------- ### Install Sendblue API with aiohttp Support Source: https://docs.sendblue.com/api/python Install the Sendblue API library with optional aiohttp support for improved concurrency performance. ```bash pip install sendblue[aiohttp] ``` -------------------------------- ### Install Sendblue API Python Library Source: https://docs.sendblue.com/api/python Install the Sendblue API Python library from PyPI using pip. ```bash pip install sendblue ``` -------------------------------- ### Webhook Creation Response Example Source: https://docs.sendblue.com/api/python/resources/webhooks/methods/create This is an example of a successful response when adding webhooks. It confirms the addition and lists the webhook types configured. ```json { "message": "Webhooks added successfully", "status": "OK", "webhooks": { "call_log": [ "https://example.com" ], "contact_created": [ "https://example.com" ], "globalSecret": "whsec_global123", "line_assigned": [ "https://example.com" ], "line_blocked": [ "https://example.com" ], "outbound": [ "https://example.com" ], "receive": [ "https://example.com" ], "typing_indicator": [ "https://example.com" ] } } ``` -------------------------------- ### Bulk Create Response Example Source: https://docs.sendblue.com/api/python/resources/contacts/subresources/bulk/methods/create This is an example of a successful response when creating multiple contacts in bulk. ```json { "contacts": [ { "assigned_to_email": "agent@example.com", "company_name": "Example Corp", "created_at": "2024-01-15T10:30:00Z", "custom_variables": { "Lead Source": "Website", "Plan": "Enterprise" }, "first_name": "John", "last_name": "Doe", "opt_out": false, "phone": "+1234567890", "sendblue_number": "+1987654321", "tags": [ "customer", "vip" ], "verified": true } ], "status": "OK" } ``` -------------------------------- ### Install libphonenumber-js Source: https://docs.sendblue.com/guides/imessage-link-button Install the libphonenumber-js library to handle phone number parsing, validation, and formatting. ```bash npm install libphonenumber-js ``` -------------------------------- ### Install TextMe Requirements Source: https://docs.sendblue.com/getting-started Install the necessary npm packages for the TextMe project, which integrates Claude AI with iMessage. ```bash npm install -g @sendblue/cli npm install -g @anthropic-ai/claude-code ``` -------------------------------- ### Complete Sendblue Account Setup with Email and Code Source: https://docs.sendblue.com/getting-started Finalize Sendblue account setup after email verification. Provide the verification code, company name, and contact phone number. ```bash npx -y @sendblue/cli setup --email you@example.com --code 12345678 --company my-agent --contact +15551234567 ``` -------------------------------- ### Direct File Upload Python Example Source: https://docs.sendblue.com/api-v2/media This Python example demonstrates how to upload a file using the requests library. It prints the media_url from the JSON response. ```Python import requests url = 'https://api.sendblue.com/api/upload-file' files = {'file': open('document.pdf', 'rb')} headers = { 'sb-api-key-id': 'YOUR_API_KEY', 'sb-api-secret-key': 'YOUR_API_SECRET' } response = requests.post(url, files=files, headers=headers) print(response.json()['media_url']) ``` -------------------------------- ### Install MCP Server via npx Source: https://docs.sendblue.com/mcp Install the MCP server using npm. Ensure your API key and secret are set as environment variables. ```bash export SENDBLUE_API_API_KEY="your-api-key" export SENDBLUE_API_API_SECRET="your-api-secret" npx -y sendblue-api-mcp@latest ``` -------------------------------- ### Node.js Example to Send Reaction Source: https://docs.sendblue.com/api-v2/reactions This Node.js example uses the axios library to send a tapback reaction. It includes the necessary headers for authentication and content type. ```javascript const axios = require('axios'); await axios.post( 'https://api.sendblue.com/api/send-reaction', { from_number: '+19175551234', message_handle: 'E8F2C3D1-A5B7-4E9F-8C1D-2A3B4C5D6E7F', reaction: 'love' }, { headers: { 'sb-api-key-id': 'YOUR_API_KEY', 'sb-api-secret-key': 'YOUR_API_SECRET', 'Content-Type': 'application/json' } } ); ``` -------------------------------- ### Example Request to List Available Area Codes (cURL) Source: https://docs.sendblue.com/api-v2/subaccounts Use this cURL command to make a GET request to the API for available area codes. Replace placeholders with your actual API key and secret. ```bash curl -X GET "https://api.sendblue.co/accounts/lines/available-area-codes" \ -H "sb-api-key-id: YOUR_API_KEY" \ -H "sb-api-secret-key: YOUR_API_SECRET" ``` -------------------------------- ### Send Read Receipt Request Example (Python) Source: https://docs.sendblue.com/api-v2/read-receipts Python example for sending a read receipt using the requests library. Shows how to construct the POST request with a JSON payload and necessary authentication headers. ```python import requests response = requests.post( 'https://api.sendblue.com/api/mark-read', json={ 'number': '+14155551234', 'from_number': '+19175551234' }, headers={ 'sb-api-key-id': 'YOUR_API_KEY', 'sb-api-secret-key': 'YOUR_API_SECRET' } ) ``` -------------------------------- ### Install openclaw-sendblue Plugin Source: https://docs.sendblue.com/getting-started Clone the openclaw-sendblue repository into the openclaw extensions directory and install its dependencies. This adds iMessage/SMS as a communication channel for your AI agent. ```bash git clone https://github.com/njerschow/openclaw-sendblue ~/.openclaw/extensions/sendblue cd ~/.openclaw/extensions/sendblue && npm install && npm run build ``` -------------------------------- ### Example: Delete Message Source: https://docs.sendblue.com/api-v2/messages This example demonstrates how to delete a message using its handle. This action only removes the message from Sendblue's database. ```bash curl -X DELETE "https://api.sendblue.com/api/message/5a17319e-cbcf-443e-897e-d8b0c04b1b09" \ -H "sb-api-key-id: YOUR_API_KEY" \ -H "sb-api-secret-key: YOUR_API_SECRET" ``` -------------------------------- ### 200 OK Response Example Source: https://docs.sendblue.com/api/python/resources/v2/subresources/totp/subresources/secrets/methods/list This is an example of a successful response when listing TOTP secrets. It includes details for each secret, such as its ID, algorithm, and label. The 'secret' field is only returned during creation, not during listing. ```json { "status": "OK", "totp_secrets": [ { "id": "550e8400-e29b-41d4-a716-446655440000", "algorithm": "SHA1", "created_at": "2026-04-05T12:00:00Z", "digits": 6, "issuer": "GitHub", "label": "GitHub - agent@example.com", "period": 30, "secret": "JBSWY3DPEHPK3PXP" } ] } ``` -------------------------------- ### Upload from URL Node.js Example Source: https://docs.sendblue.com/api-v2/media This Node.js example uses axios to upload media from a URL. It sends the media_url in the request body and includes the necessary authentication and content type headers. ```JavaScript const axios = require('axios'); const response = await axios.post( 'https://api.sendblue.com/api/upload-media-object', { media_url: 'https://example.com/image.jpg' }, { headers: { 'sb-api-key-id': 'YOUR_API_KEY', 'sb-api-secret-key': 'YOUR_API_SECRET', 'Content-Type': 'application/json' } } ); console.log(response.data.mediaObjectId); ``` -------------------------------- ### Example Seat List Response Source: https://docs.sendblue.com/api/python/resources/v2/subresources/seats/methods/list An example of the JSON response when successfully listing seats. Each item represents a seat with details like account, email, and seat ID. ```json [ { "account": "acmeco", "created_at": "2024-06-15T18:24:01Z", "email": "rep@example.com", "first_name": "Jane", "forwarding_number": "+19998887777", "last_name": "Doe", "seat_id": "550e8400-e29b-41d4-a716-446655440000" } ] ``` -------------------------------- ### Opt Out Response Example Source: https://docs.sendblue.com/api/python/resources/contacts/methods/opt_out This is an example of a successful response when opting a contact out. It includes the normalized phone number, the opt-out status, and the operation status. ```json { "number": "+14155551234", "opted_out": true, "status": "OK" } ``` -------------------------------- ### Send Read Receipt Request Example (Node.js) Source: https://docs.sendblue.com/api-v2/read-receipts Example of sending a read receipt using Node.js with the axios library. Demonstrates setting up the request URL, body, and headers, including API keys and content type. ```javascript const axios = require('axios'); await axios.post( 'https://api.sendblue.com/api/mark-read', { number: '+14155551234', from_number: '+19175551234' }, { headers: { 'sb-api-key-id': 'YOUR_API_KEY', 'sb-api-secret-key': 'YOUR_API_SECRET', 'Content-Type': 'application/json' } } ); ``` -------------------------------- ### Direct File Upload Node.js Example Source: https://docs.sendblue.com/api-v2/media This Node.js example uses axios and form-data to upload a file. It logs the media_url upon successful upload, which can then be used in the send-message endpoint. ```JavaScript const axios = require('axios'); const FormData = require('form-data'); const fs = require('fs'); const form = new FormData(); form.append('file', fs.createReadStream('./document.pdf')); const response = await axios.post( 'https://api.sendblue.com/api/upload-file', form, { headers: { ...form.getHeaders(), 'sb-api-key-id': 'YOUR_API_KEY', 'sb-api-secret-key': 'YOUR_API_SECRET' } } ); console.log(response.data.media_url); // Use this URL in send-message endpoint ``` -------------------------------- ### Start a Call Source: https://docs.sendblue.com/calling/facetime Initiates a FaceTime call to a specified phone number. ```APIDOC ## POST /facetime/start-call ### Description Initiates a FaceTime call to a specified phone number. ### Method POST ### Endpoint https://api.sendblue.com/facetime/start-call ### Parameters #### Request Body - **phoneNumber** (string) - Required - The phone number to call (E.164 format) - **fromNumber** (string) - Required - Your Sendblue FaceTime number (E.164 format) ### Request Example ```json { "phoneNumber": "+14155550123", "fromNumber": "+18885550199" } ``` ### Response #### Success Response (200) - **status** (string) - Request status (`OK` on success) - **message** (string) - Human-readable status message - **agora.appId** (string) - Agora application ID for joining the channel - **agora.channelName** (string) - Unique channel name for this call - **agora.token** (string) - Authentication token for joining the channel - **agora.uid** (number) - User ID to use when joining (use `0` for auto-assign) #### Response Example ```json { "status": "OK", "message": "Call started", "agora": { "appId": "a1b2c3d4e5f6789012345678abcdef90", "channelName": "ft_call_9f8e7d6c5b4a3210", "token": "007eJxTYDhw4MCBAwcOHDhw4MCB...", "uid": 0 } } ``` ``` -------------------------------- ### SMS URL Example Source: https://docs.sendblue.com/guides/imessage-link-button This is an example of an `sms:` URL that can be used to open the Messages app with a pre-filled phone number and body. The number must be in E.164 format, and the body must be URL-encoded. ```url sms:+15551234567&body=Hello%20from%20Sendblue ``` -------------------------------- ### Idempotent Webhook Handler Example Source: https://docs.sendblue.com/getting-started/webhooks This example demonstrates how to create an idempotent webhook handler using a Set to track processed message handles, preventing duplicate processing. ```javascript const processedMessages = new Set(); app.post("/webhook", (req, res) => { const { message_handle } = req.body; if (processedMessages.has(message_handle)) { return res.status(200).send("Already processed"); } processedMessages.add(message_handle); // Process the webhook... res.status(200).send("OK"); }); ``` -------------------------------- ### Example Contact List Response Source: https://docs.sendblue.com/api/python/resources/contacts/methods/list This is an example of the JSON response when retrieving a list of contacts. It includes details such as assigned user, company, creation date, custom variables, names, opt-out status, phone numbers, tags, and verification status. ```json [ { "assigned_to_email": "agent@example.com", "company_name": "Example Corp", "created_at": "2024-01-15T10:30:00Z", "custom_variables": { "Lead Source": "Website", "Plan": "Enterprise" }, "first_name": "John", "last_name": "Doe", "opt_out": false, "phone": "+1234567890", "sendblue_number": "+1987654321", "tags": [ "customer", "vip" ], "verified": true } ] ``` -------------------------------- ### Setting up a webhook with a secret Source: https://docs.sendblue.com/getting-started/webhooks This example demonstrates how to configure a new webhook with a specific secret for enhanced security. ```APIDOC ## POST /api/account/webhooks ### Description Configures a new webhook with specified settings. ### Method POST ### Endpoint /api/account/webhooks ### Request Body - **webhooks** (array) - Required - An array of webhook objects to configure. - **url** (string) - Required - The URL to send webhook events to. - **secret** (string) - Optional - A secret key for webhook security. - **type** (string) - Required - The type of webhook (e.g., "receive", "outbound", "call_log"). ### Request Example ```json { "webhooks": [ { "url": "https://myapp.com/webhooks/sendblue", "secret": "my-secure-secret-123" } ], "type": "receive" } ``` ### Response (Response details not provided in source) ``` -------------------------------- ### Set up Sendblue Account with Email Verification via CLI Source: https://docs.sendblue.com/getting-started/credentials Initiates the setup process for a new Sendblue account using email verification. ```bash sendblue setup ``` -------------------------------- ### Get Installed Sendblue API Version Source: https://docs.sendblue.com/api/python Determine the currently installed version of the `sendblue_api` package at runtime. This is useful for debugging or ensuring compatibility with specific features. ```python import sendblue_api print(sendblue_api.__version__) ``` -------------------------------- ### Get Profile State Success Response Source: https://docs.sendblue.com/api-v2/contact-sharing This is an example of a successful response when checking the state of a contact sharing profile. ```json { "status": "OK", "data": { "hasProfile": true, "firstName": "Jane", "lastName": "Smith", "displayName": "Jane at Acme" } } ``` -------------------------------- ### Configure Typing Indicator Webhook Source: https://docs.sendblue.com/api-v2/typing-indicators Register a webhook for the `typing_indicator` event type to receive real-time notifications when contacts start or stop typing. This example uses cURL. ```curl curl -X POST 'https://api.sendblue.com/api/account/webhooks' \ -H 'sb-api-key-id: YOUR_API_KEY' \ -H 'sb-api-secret-key: YOUR_API_SECRET' \ -H 'Content-Type: application/json' \ -d '{ "webhooks": ["https://your-server.com/webhooks/typing"], "type": "typing_indicator" }' ``` -------------------------------- ### Set up Sendblue Account with Phone Verification via CLI Source: https://docs.sendblue.com/getting-started/credentials Initiates the setup process for a new Sendblue account using phone verification, specifying a phone number and company name. ```bash sendblue setup --phone +15551234567 --company my-agent ``` -------------------------------- ### Node.js Webhook Handler for Typing Indicators Source: https://docs.sendblue.com/api-v2/typing-indicators Example of a Node.js webhook handler using Express to process incoming typing indicator events. It logs whether a contact has started or stopped typing. ```javascript const express = require('express'); const app = express(); app.use(express.json()); app.post('/webhooks/typing', (req, res) => { const { number, is_typing, from_number, timestamp } = req.body; if (is_typing) { console.log(`${number} started typing...`); // Show typing indicator in your UI } else { console.log(`${number} stopped typing`); // Hide typing indicator in your UI } res.status(200).send('OK'); }); app.listen(3000); ``` -------------------------------- ### Configure TextMe Project Source: https://docs.sendblue.com/getting-started Create the configuration file for TextMe. This involves setting up Sendblue API credentials and whitelisting phone numbers. ```bash mkdir -p ~/.config/claude-imessage ``` ```json { "sendblue": { "apiKey": "YOUR_API_KEY", "apiSecret": "YOUR_API_SECRET", "phoneNumber": "+1SENDBLUE_NUMBER" }, "whitelist": ["+1YOUR_PHONE"] } ``` -------------------------------- ### Example Request to List Available Area Codes (Python) Source: https://docs.sendblue.com/api-v2/subaccounts This Python snippet shows how to get available area codes using the requests library. Provide your API key and secret in the request headers. ```python import requests response = requests.get( "https://api.sendblue.co/accounts/lines/available-area-codes", headers={ "sb-api-key-id": "YOUR_API_KEY", "sb-api-secret-key": "YOUR_API_SECRET" } ) ``` -------------------------------- ### Get Seat Count using Python Source: https://docs.sendblue.com/api/python/resources/v2/subresources/seats/methods/count Use this snippet to retrieve the total number of seats for your Sendblue account. Ensure you have the 'sendblue_api' library installed and your API key and secret are set as environment variables. ```python import os from sendblue_api import SendblueAPI client = SendblueAPI( api_key=os.environ.get("SENDBLUE_API_API_KEY"), # This is the default and can be omitted api_secret=os.environ.get("SENDBLUE_API_API_SECRET"), # This is the default and can be omitted ) response = client.v2.seats.count() print(response.count) ``` -------------------------------- ### Handle Incoming Typing Indicator Webhook Source: https://docs.sendblue.com/api-v2/typing-indicators This Python Flask example demonstrates how to receive and process webhook POST requests for typing indicator events. It checks the 'is_typing' status and logs whether a contact started or stopped typing. ```python from flask import Flask, request app = Flask(__name__) @app.route('/webhooks/typing', methods=['POST']) def handle_typing(): data = request.json number = data.get('number') is_typing = data.get('is_typing') if is_typing: print(f'{number} started typing...') # Show typing indicator in your UI else: print(f'{number} stopped typing') # Hide typing indicator in your UI return 'OK', 200 ``` -------------------------------- ### Delete Contact Response Example Source: https://docs.sendblue.com/api/python/resources/contacts/methods/delete This is an example of a successful response when deleting a contact. ```json { "status": "OK" } ``` -------------------------------- ### Example: Delete Message Response Source: https://docs.sendblue.com/api-v2/messages This is an example of the JSON response after successfully deleting a message. ```json { "status": "OK", "message": "Message deleted" } ``` -------------------------------- ### Preview Line Provisioning Success Response Source: https://docs.sendblue.com/api-v2/line-provisioning A successful response indicates eligibility and provides a preview token valid for 10 minutes. ```json { "status": "OK", "preview_token": "lpv_abc123...", "expires_at": "2026-05-18T14:30:00.000Z", "message": "Call the confirm endpoint with this token within 10 minutes to complete the purchase." } ``` -------------------------------- ### Instantiate Client with Fetch Options Source: https://docs.sendblue.com/api/typescript Provide a `fetchOptions` object when instantiating the client to set custom fetch configurations. Request-specific options override client options. ```typescript import SendblueAPI from 'sendblue'; const client = new SendblueAPI({ fetchOptions: { // `RequestInit` options }, }); ``` -------------------------------- ### Delete Webhook Response Example Source: https://docs.sendblue.com/api/python/resources/webhooks/methods/delete This is an example of a successful response when deleting webhooks. It confirms the action and provides a status. ```json { "message": "Webhooks deleted successfully", "status": "OK" } ``` -------------------------------- ### Message Response Example Source: https://docs.sendblue.com/api/python/resources/groups/methods/send_message An example of a successful response when sending a group message. This shows the structure of the MessageResponse object. ```json { "account_email": "user@example.com", "content": "Hello, World!", "date_created": "2023-10-01T12:00:00Z", "date_updated": "2023-10-01T12:00:01Z", "error_code": 0, "error_message": "error_message", "from_number": "+19998887777", "is_outbound": true, "media_url": "https://cdn.sendblue.co/media/abc123.jpg", "message_handle": "msg_abc123def456", "number": "+18887776666", "seat_id": "550e8400-e29b-41d4-a716-446655440000", "send_style": "celebration", "sender_email": "rep@example.com", "status": "QUEUED" } ``` -------------------------------- ### Lookup Number API Response Example Source: https://docs.sendblue.com/api/python/resources/lookups/methods/lookup_number This is an example of a successful response when looking up a phone number, indicating it supports iMessage. ```json { "number": "+19999999999", "service": "iMessage" } ``` -------------------------------- ### Start FaceTime Call Source: https://docs.sendblue.com/llms.txt Initiates a programmatic FaceTime call using Agora WebRTC credentials. ```APIDOC ## POST /facetime/start-call ### Description Initiates a programmatic FaceTime call. This endpoint returns Agora WebRTC credentials required to join and stream audio using the Agora Voice SDK. Requires a purchased FaceTime line. ### Method POST ### Endpoint /facetime/start-call ### Parameters #### Request Body - **from_number** (string) - Required - The sender's phone number. - **to_number** (string) - Required - The recipient's phone number. ### Request Example { "from_number": "+1234567890", "to_number": "+1987654321" } ### Response #### Success Response (200) - **appId** (string) - Agora App ID. - **channelName** (string) - Agora Channel Name. - **token** (string) - Agora Token. - **uid** (integer) - Agora User ID. ### Response Example { "appId": "your_agora_app_id", "channelName": "call_channel_123", "token": "generated_agora_token", "uid": 123456789 } ``` -------------------------------- ### Show Sendblue API Keys via CLI Source: https://docs.sendblue.com/getting-started/credentials Use this command to display your existing API keys. Recommended for new accounts. ```bash sendblue show-keys ``` -------------------------------- ### Step 1: Preview Line Provisioning Source: https://docs.sendblue.com/api-v2/line-provisioning Validates account eligibility and line availability, issuing a short-lived preview token for the confirmation step. This endpoint is used to initiate the line provisioning process. ```APIDOC ## POST /accounts/lines/provision-preview ### Description Validates that the account is eligible and a line is currently available. The response includes a `preview_token` that is valid for 10 minutes. ### Method POST ### Endpoint /accounts/lines/provision-preview ### Request Example ``` curl -X POST "https://api.sendblue.com/accounts/lines/provision-preview" \ -H "sb-api-key-id: YOUR_API_KEY" \ -H "sb-api-secret-key: YOUR_API_SECRET" ``` ### Response #### Success Response (200) - **status** (string) - `OK` - **preview_token** (string) - Single-use token for the confirm step - **expires_at** (string) - ISO 8601 expiration timestamp - **message** (string) - Human-readable next step #### Response Example ```json { "status": "OK", "preview_token": "lpv_abc123...", "expires_at": "2026-05-18T14:30:00.000Z", "message": "Call the confirm endpoint with this token within 10 minutes to complete the purchase." } ``` ``` -------------------------------- ### Async Usage with aiohttp Backend Source: https://docs.sendblue.com/api/python Demonstrates using the asynchronous client with `aiohttp` as the HTTP backend by instantiating `DefaultAioHttpClient()`. ```python import os import asyncio from sendblue_api import DefaultAioHttpClient from sendblue_api import AsyncSendblueAPI async def main() -> None: async with AsyncSendblueAPI( api_key=os.environ.get("SENDBLUE_API_API_KEY"), # This is the default and can be omitted api_secret=os.environ.get( "SENDBLUE_API_API_SECRET" ), # This is the default and can be omitted http_client=DefaultAioHttpClient(), ) as client: message_response = await client.messages.send( content="REPLACE_ME", from_number="REPLACE_ME", number="REPLACE_ME", ) print(message_response.seat_id) asyncio.run(main()) ``` -------------------------------- ### Step 2: Confirm Line Provisioning Source: https://docs.sendblue.com/api-v2/line-provisioning Consumes the preview token, charges the card on file, and provisions the new inbound-only phone line. This is the final step to complete the line purchase. ```APIDOC ## POST /accounts/lines/provision-confirm ### Description Consume the `preview_token`, charge the card on file, and provision the line. ### Method POST ### Endpoint /accounts/lines/provision-confirm ### Parameters #### Request Body - **preview_token** (string) - Required - Token returned by `POST /accounts/lines/provision-preview` ### Request Example ``` curl -X POST "https://api.sendblue.com/accounts/lines/provision-confirm" \ -H "sb-api-key-id: YOUR_API_KEY" \ -H "sb-api-secret-key: YOUR_API_SECRET" \ -H "Content-Type: application/json" \ -d '{ "preview_token": "lpv_abc123..." }' ``` ### Response #### Success Response (200) - **status** (string) - `OK` - **phone_number** (string) - The newly provisioned Sendblue phone number - **worker_id** (string) - Internal worker ID for the new line - **subscription_id** (string) - Stripe subscription ID for the line #### Response Example ```json { "status": "OK", "phone_number": "+14155551234", "worker_id": "worker_abc123", "subscription_id": "sub_abc123" } ``` ``` -------------------------------- ### Example TOTP Code Response Source: https://docs.sendblue.com/api/python/resources/v2/subresources/totp/methods/get_code This is an example of a successful response when fetching a TOTP code. It includes the code itself, the time remaining until rotation, and the status. ```json { "code": "482031", "expires_in": 14, "status": "OK" } ``` -------------------------------- ### Get Seat Count in TypeScript Source: https://docs.sendblue.com/api/typescript/resources/v2/subresources/seats/methods/count Use this snippet to get the total number of seats for your company. Ensure your API key and secret are configured. ```typescript import SendblueAPI from 'sendblue'; const client = new SendblueAPI({ apiKey: process.env['SENDBLUE_API_API_KEY'], // This is the default and can be omitted apiSecret: process.env['SENDBLUE_API_API_SECRET'], // This is the default and can be omitted }); const response = await client.v2.seats.count(); console.log(response.count); ``` -------------------------------- ### Preview API line provisioning Source: https://docs.sendblue.com/api-v2 Previews the process of provisioning a new API line and obtains a token. ```APIDOC ## POST /accounts/lines/provision-preview ### Description Preview API line provisioning and receive a token. ### Method POST ### Endpoint /accounts/lines/provision-preview ``` -------------------------------- ### Get contact count Source: https://docs.sendblue.com/api/python/resources/contacts/methods/count Retrieves the total number of contacts. This method corresponds to the `contacts.count()` function in the Python SDK and the `GET /api/v2/contacts/count` endpoint. ```APIDOC ## GET /api/v2/contacts/count ### Description Get the total number of contacts. ### Method GET ### Endpoint /api/v2/contacts/count ### Response #### Success Response (200) - **count** (Optional[int]) - Total number of contacts ### Response Example ```json { "count": 0 } ``` ``` -------------------------------- ### Clone and Build TextMe AI Chatbot Daemon Source: https://docs.sendblue.com/getting-started/quickstart Clone the TextMe repository, navigate to the daemon directory, install dependencies, and build the project for an iMessage AI chatbot. ```bash git clone https://github.com/njerschow/textme.git cd textme/daemon && npm install && npm run build ``` -------------------------------- ### Create Webhook with URL Source: https://docs.sendblue.com/api/python/resources/webhooks/methods/create Adds a new webhook to your account using a simple URL. Ensure your API key and secret are set as environment variables. ```python import os from sendblue_api import SendblueAPI client = SendblueAPI( api_key=os.environ.get("SENDBLUE_API_API_KEY"), # This is the default and can be omitted api_secret=os.environ.get("SENDBLUE_API_API_SECRET"), # This is the default and can be omitted ) webhook = client.webhooks.create( webhooks=["https://example.com"], ) print(webhook.message) ``` -------------------------------- ### Message Retrieve Response Example Source: https://docs.sendblue.com/api/python/resources/messages/methods/retrieve This is an example of a successful response when retrieving message details. It includes information about the message content, sender, recipient, and status. ```json { "data": { "accountEmail": "user@example.com", "content": "Hello, World!", "date_sent": "2024-01-01T12:00:00Z", "date_updated": "2024-01-01T12:00:01Z", "error_code": null, "error_detail": null, "error_message": null, "error_reason": null, "from_number": "+19998887777", "group_display_name": null, "group_id": null, "is_outbound": true, "media_url": null, "message_handle": "msg_abc123def456", "message_type": "message", "number": "+18887776666", "opted_out": false, "participants": [ "string" ], "plan": "premium", "seat_id": "550e8400-e29b-41d4-a716-446655440000", "send_style": "celebration", "sendblue_number": "+19998887777", "sender_email": "rep@example.com", "service": "iMessage", "status": "SENT", "to_number": "+18887776666", "was_downgraded": false }, "status": "OK" } ``` -------------------------------- ### API Response Example for Seat Count Source: https://docs.sendblue.com/api/python/resources/v2/subresources/seats/methods/count This is an example of a successful response when retrieving the seat count. The 'count' field indicates the total number of seats. ```json { "count": 12 } ``` -------------------------------- ### Error Response: No URL Provided Source: https://docs.sendblue.com/api-v2/media This error response is returned when attempting to upload media from a URL but the 'media_url' parameter is missing. ```JSON { "status": "ERROR", "message": "No media url specified" } ``` -------------------------------- ### Bulk Delete Response Example Source: https://docs.sendblue.com/api/python/resources/contacts/subresources/bulk/methods/delete This is an example of a successful response when deleting multiple contacts in bulk. It indicates the number of contacts deleted and the status of the operation. ```json { "amount": 0, "status": "OK" } ``` -------------------------------- ### Configure Deno Proxy Source: https://docs.sendblue.com/api/typescript Configure Deno proxy behavior by providing custom `fetchOptions` with a `client` option referencing a `Deno.HttpClient` configured with proxy settings. This allows runtime-specific proxy options for requests. ```typescript import SendblueAPI from 'npm:sendblue'; const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } }); const client = new SendblueAPI({ fetchOptions: { client: httpClient, }, }); ``` -------------------------------- ### Interactive Sendblue CLI Usage Source: https://docs.sendblue.com/llms.txt Perform setup, add a contact, and send a message using interactive Sendblue CLI commands. ```bash npx -y @sendblue/cli setup npx -y @sendblue/cli add-contact +15551234567 npx -y @sendblue/cli send +15551234567 'Hello from Sendblue!' ``` -------------------------------- ### Webhook List Response Example Source: https://docs.sendblue.com/api/python/resources/webhooks/methods/list This is a sample JSON response when successfully retrieving the list of webhooks. It shows the status and the different types of webhooks configured, including URLs and global secrets. ```json { "status": "OK", "webhooks": { "call_log": [ "https://example.com" ], "contact_created": [ "https://example.com" ], "globalSecret": "whsec_global123", "line_assigned": [ "https://example.com" ], "line_blocked": [ "https://example.com" ], "outbound": [ "https://example.com" ], "receive": [ "https://example.com" ], "typing_indicator": [ "https://example.com" ] } } ``` -------------------------------- ### Preview Line Provisioning Request Source: https://docs.sendblue.com/api-v2/line-provisioning Use this endpoint to validate account eligibility and line availability. It returns a short-lived preview token. ```curl curl -X POST "https://api.sendblue.com/accounts/lines/provision-preview" \ -H "sb-api-key-id: YOUR_API_KEY" \ -H "sb-api-secret-key: YOUR_API_SECRET" ``` -------------------------------- ### Provision Line Preview Source: https://docs.sendblue.com/llms.txt Initiates a preview for provisioning an inbound-only line, returning a temporary token. ```APIDOC ## POST /accounts/lines/provision-preview ### Description Initiates a preview for provisioning an inbound-only line. This endpoint returns a 10-minute `preview_token` that must be used to confirm the provisioning. ### Method POST ### Endpoint /accounts/lines/provision-preview ### Response #### Success Response (200) - **preview_token** (string) - A token valid for 10 minutes to confirm line provisioning. ``` -------------------------------- ### Get Seat Count using cURL Source: https://docs.sendblue.com/api/resources/v2/subresources/seats/methods/count Use this cURL command to make a GET request to the /api/v2/seats/count endpoint. Ensure you replace the placeholder API keys with your actual credentials. ```bash curl https://api.sendblue.co/api/v2/seats/count \ -H "sb-api-key-id: $SENDBLUE_API_API_KEY" \ -H "sb-api-secret-key: $SENDBLUE_API_API_SECRET" ``` -------------------------------- ### Upload File and Send Message with Media Source: https://docs.sendblue.com/api-v2/media This snippet demonstrates the two-step process of uploading a file and then sending a message that includes the uploaded media. Ensure you have the necessary authentication headers and form data prepared. ```javascript // 1. Upload the file const uploadResponse = await axios.post( 'https://api.sendblue.com/api/upload-file', formData, { headers: { ...form.getHeaders(), ...authHeaders } } ); // 2. Send message with the uploaded media await axios.post( 'https://api.sendblue.com/api/send-message', { number: '+14155551234', from_number: '+19175551234', content: 'Check out this document!', media_url: uploadResponse.data.media_url }, { headers: authHeaders } ); ```