Skip to main content

API Reference

What it is

The BotBat API Reference is the complete technical documentation for the REST API that powers every feature of the platform. It provides detailed specifications for authentication using Bearer tokens, base URL and versioning conventions, request and response formats, cursor-based pagination, standardized error codes, and per-endpoint rate limits. Every operation you can perform in the BotBat console has a corresponding API endpoint, making it possible to fully automate your messaging, contact management, and campaign workflows.

The API follows RESTful design principles. Resources are identified by URL paths, standard HTTP methods indicate the operation (GET for reading, POST for creating, PUT/PATCH for updating, DELETE for removing), and all data exchange uses JSON. The versioning strategy is URL-based: the current version is v1, and future versions will use /v2, /v3, etc., ensuring backward compatibility for existing integrations while allowing the API to evolve.

The interactive API Reference, accessible from the Developer section of the BotBat console, goes beyond static documentation. It includes a built-in "Try It" panel where you can construct requests, execute them against the sandbox environment, and inspect the full response including headers, status codes, and JSON bodies. This makes it the fastest way to explore the API and understand how each endpoint behaves before writing any integration code.

API Reference landing page with interactive docs showing endpoint categories in sidebar

When to use

ScenarioDescription
Starting a new API integrationBegin here to understand the base URL, authentication mechanism, and common patterns before writing any code.
Looking up a specific endpointFind the exact request format, required parameters, optional parameters, and expected response shape for any API operation.
Debugging an error responseReference the error codes table to understand what a specific HTTP status code and error body mean and how to resolve the issue.
Implementing paginationLearn how to use cursor-based pagination to efficiently iterate through large result sets without missing or duplicating records.
Understanding rate limits per endpointCheck the rate limit for a specific endpoint to design your integration's request frequency appropriately.
Onboarding new developersShare the API Reference with new team members so they can self-serve when building or maintaining integrations.

Steps

1. Identify the base URL

All API requests use the base URL https://api.botbat.com/v1. The version number is included in the URL path. When a new version is released, existing v1 endpoints will continue to function for a documented deprecation period, giving you time to migrate.

2. Authenticate your requests

Include your API key as a Bearer token in the Authorization header of every request. The format is Authorization: Bearer YOUR_API_KEY. Requests without a valid token receive an HTTP 401 response. API keys are created and managed in the Developer dashboard. Each key is scoped to specific permissions, so ensure your key has the required scopes for the endpoints you intend to call.

3. Set request headers

All requests must include Content-Type: application/json and Accept: application/json. Request bodies are JSON-encoded, and all responses are returned as JSON. Binary uploads (such as CSV imports) use multipart/form-data instead.

4. Make a request

Construct your HTTP request with the appropriate method (GET, POST, PUT, PATCH, DELETE), the endpoint path, query parameters for filtering and pagination, and a JSON request body for create and update operations. The interactive documentation provides copy-ready code snippets in cURL, JavaScript, Python, and PHP for every endpoint.

Endpoint detail view showing method, path, parameters, and request/response schema

5. Use the Try It panel

The Try It panel in the interactive documentation lets you execute requests directly from the browser. Select an endpoint, fill in the parameters and request body, attach your sandbox API key, and click Send. The panel displays the full response including HTTP status, response headers, and the JSON body.

Try It panel with request builder showing headers, body fields, and Send button

This is the fastest way to explore unfamiliar endpoints and verify that your request payloads are correctly structured before integrating them into your codebase.

6. Handle pagination

List endpoints return paginated results. Each response includes a data array containing the current page of results and a cursor field. To retrieve the next page, include ?cursor=RETURNED_CURSOR as a query parameter in your subsequent request. When the cursor field is null, you have reached the end of the result set. The default page size is 25 items, and you can adjust it with the limit query parameter (maximum 100).

Pagination example showing response body with data array and cursor field

7. Parse successful responses

Successful responses return HTTP 200 for read and update operations, or HTTP 201 for creation operations. The response body contains the requested data. For single-resource endpoints, the data is returned directly. For list endpoints, the response includes data (an array of resources), cursor (for pagination), and total (the total count of matching resources).

Successful response example showing 200 status with JSON body

8. Handle errors

Error responses include an HTTP status code, an error object with a machine-readable code, a human-readable message, and optionally a details array for validation errors. Always check the status code first, then parse the error body for specifics.

Error response example showing 422 status with validation error details

Key endpoints

Campaigns API

MethodEndpointDescription
GET/v1/campaignsList campaigns, filterable by status and date range
POST/v1/campaignsCreate a new campaign
GET/v1/campaigns/:idGet campaign details
PUT/v1/campaigns/:idUpdate a campaign
DELETE/v1/campaigns/:idDelete a draft campaign
POST/v1/campaigns/:id/sendSend or schedule a campaign

The Campaigns API lets you create, manage, and send campaigns programmatically. You can filter campaign lists by status (draft, scheduled, sending, completed, failed) and by date range. The POST /send endpoint accepts optional scheduling parameters; omitting them sends the campaign immediately.

Contacts API

MethodEndpointDescription
GET/v1/contactsList contacts, filterable by segment, tag, and date
POST/v1/contactsCreate a contact
GET/v1/contacts/:idGet contact details
PUT/v1/contacts/:idUpdate a contact
DELETE/v1/contacts/:idDelete a contact
GET/v1/contacts/search?q=Search contacts by name, email, or phone
POST/v1/contacts/importBulk import contacts via CSV upload

The Contacts API supports full CRUD operations as well as search and bulk import. The search endpoint performs a fuzzy match across name, email, and phone fields. The import endpoint accepts a CSV file via multipart/form-data and returns a job ID that you can poll for completion status.

Messages API

MethodEndpointDescription
POST/v1/messages/sendSend a message to a contact
GET/v1/messages/:idGet message details and delivery status

The Messages API handles individual message sending and status tracking. The send endpoint requires a contact_id, channel (e.g., whatsapp, sms), and either a template_id or a body for freeform messages. The status endpoint returns the full delivery lifecycle: queued, sent, delivered, read, or failed.

Conversations API

MethodEndpointDescription
GET/v1/conversationsList conversations, filterable by status and assignee
GET/v1/conversations/:idGet conversation details with message history
POST/v1/conversations/:id/assignAssign a conversation to an agent
POST/v1/conversations/:id/resolveResolve a conversation

Templates API

MethodEndpointDescription
GET/v1/templatesList message templates
POST/v1/templatesCreate a template
GET/v1/templates/:idGet template details
PUT/v1/templates/:idUpdate a template
DELETE/v1/templates/:idDelete a template
POST/v1/templates/:id/submitSubmit a template for WhatsApp approval

Webhooks API

MethodEndpointDescription
GET/v1/webhooksList webhook endpoints
POST/v1/webhooksCreate a webhook endpoint
GET/v1/webhooks/:idGet webhook details
PUT/v1/webhooks/:idUpdate a webhook endpoint
DELETE/v1/webhooks/:idDelete a webhook endpoint

Common error codes

HTTP StatusError CodeDescriptionResolution
400invalid_requestMalformed request body or missing required fieldsCheck the request body structure against the endpoint schema.
401unauthorizedMissing or invalid API keyVerify that the Authorization header contains a valid Bearer token.
403forbiddenAPI key lacks the required scope for this endpointUpdate the key's scopes in the Developer dashboard or use a different key.
404not_foundThe requested resource does not existConfirm the resource ID is correct and belongs to your organization.
409conflictResource state conflict (e.g., sending an already-sent campaign)Check the current state of the resource before attempting the operation.
422validation_errorRequest body fails validation; check the details arrayFix the fields listed in the details array and retry.
429rate_limitedRate limit exceededWait for the number of seconds specified in the Retry-After header, then retry.
500internal_errorServer errorRetry with exponential backoff and jitter, up to 3 to 5 attempts.

Common pitfalls

PitfallImpactRecommendation
Using API keys without sufficient scopesRequests fail with 403, blocking your integration.Check required scopes in the endpoint documentation before generating a key.
Ignoring cursor paginationOnly the first page of results is returned, leading to incomplete data.Always paginate until cursor is null.
Not validating request bodies before sendingUnnecessary round trips due to 422 errors.Validate payloads client-side using the schemas from the API docs.
Hardcoding the API versionMakes version upgrades painful and error-prone.Store the API version in a configuration variable so upgrades require only a config change.
Not implementing retry logic for 500 errorsTransient failures cause permanent data loss or missed operations.Implement exponential backoff with jitter, retrying 3 to 5 times for 500-level responses.
tip

Use the interactive "Try It" feature in the API Reference documentation to test endpoints directly from your browser with your sandbox API key. This is the fastest way to understand request/response shapes before writing integration code.

  • API Reference
  • Endpoint Detail
  • Try It Panel
  • Pagination
  • Error Codes
  • Campaigns API
  • Contacts API
  • Messages API
  • Conversations API
  • Templates API
  • Webhooks API