> For the complete documentation index, see [llms.txt](https://docs.spara.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.spara.com/developers/spara-api/web-api.md).

# Web API

Spara's Web API supports completely customizable configurations.

The Spara platform offers powerful integration capabilities through a suite of web API endpoints. Webhooks provide real-time notifications of lead events via `POST` requests to a customer-defined endpoint, enabling automated workflows, external system synchronization, and timely responses to key updates. APIs allow customers to update and enrich lead data, manage user information, and influence the behavior of our AI engine - supporting deep, flexible integrations. All API interactions must be conducted over `HTTPS` to ensure secure communication.

Both webhooks and API support basic data types via JSON. These types are not explicitly identified in request values.

* `string`, ex. `"John Doe"`
* `integer`, ex. `100`
* `boolean`, i.e. `true` or `false`

Malformed values will be rejected, ex. `John Doe`. Take care to not cast integer or boolean values as strings, ex. `"100"`.

{% hint style="info" %}
**Using this API with a CRM integration.** By default, leads you create or update through the API are not pushed to your CRM. To have Spara create and update CRM records for API leads, turn on **Sync API leads to your CRM** under Settings → Webhooks & API. Your CRM integration's sync mode, create conditions, and field settings still apply.
{% endhint %}

### Schema

For how leads relate to accounts, owners, and deals, see [Spara Objects & Fields](https://docs.spara.com/developers/data-model/data-model.md).

Spara models leads as a single object with any number of arbitrary fields. For example, if you configure Spara to ask your leads the question "What industry is your company in?" you may decide to name that field `industry`.

The following fields are standard for all leads:

```
# Info about the lead.
email(string)
company_name (string)
first_name (string)
last_name (string)
phone_number (string)
job_title (string)
num_employees (integer)
```

The lead's CRM account and owner are returned as the `account` and `owner` objects, described in [Account](https://docs.spara.com/developers/data-model/data-model/account.md) and [Owner](https://docs.spara.com/developers/data-model/data-model/owner.md).

#### Account & owner objects

A lead may also carry the company it belongs to and the rep who owns it. Both are returned as nested objects on the lead, and both are accepted on `POST /leads` and `PATCH /leads/{id}`:

```json
{
  "account": {
    "company_name": "Test Co",
    "website": "https://test.co",
    "industry": "Software",
    "employee_count": 250,
    "annual_revenue": 40000000,
    "billing_city": "Denver",
    "crm_source": "SALESFORCE",
    "crm_id": "0011U00000XyZaBQAV",
    "owner": {
      "email": "rep@yourcompany.com",
      "full_name": "Alex Rivera",
      "role": "Account Executive",
      "is_active": true,
      "crm_source": "SALESFORCE",
      "crm_id": "0051U000004AbCdQAK"
    }
  },
  "owner": {
    "email": "rep@yourcompany.com",
    "full_name": "Alex Rivera",
    "role": "Account Executive",
    "is_active": true,
    "crm_source": "SALESFORCE",
    "crm_id": "0051U000004AbCdQAK"
  }
}
```

The lead's `owner` is the rep assigned to that person; `account.owner` is the rep assigned to the company. They are often the same record.

* `crm_source` accepts `SALESFORCE`, `HUBSPOT`, or `MARKETO`, and must be sent together with `crm_id` or the request fails with `422`. Sending both lets Spara match an existing account or owner rather than creating a duplicate.
* Any other key inside `account` or `owner` is treated as a custom field for that object and must already be defined in your Data Model, or the request fails with `422`.

### Authentication

The base URL for all API requests is: `https://api.spara.co/v1/`

All requests to the API must be authenticated using a Bearer Token in the Authorization header. Each customer can generate one or more API Keys via the user dashboard.

Header Example:

`Authorization: Bearer YOUR_API_KEY`

### Error Responses

* `400 Bad Request`: The request body is malformed JSON or contains invalid data for the metadata fields (e.g., wrong data type). The response body will provide details on the specific error.
* `401 Unauthorized`: Missing or invalid API key.
* `403 Forbidden`: API key does not have access to the specified lead.
* `404 Not Found`: Lead with the provided id does not exist.
* `422 Unprocessable Entity`: The request was well-formed, but semantic validation failed (e.g., attempting to set a field to a value that is logically impossible or not allowed, attempting to update read-only fields (e.g., ip\_address)).
* `429 Too Many Requests`: The number of requests has exceeded the limits described in [#rate-limiting](#rate-limiting "mention").

## Resource: Leads

The primary resource for this API is leads.

#### Search Leads (GET)

This endpoint allows you to search for leads by their email address. The response will include a unique identifier (id) for each lead, and all known fields about the lead. Zero (no lead found), one (only one lead found), or multiple leads (if there are multiple leads with the same email address) could be returned from this endpoint.

Endpoint: `/leads/search`

Method: `GET`

Description: Retrieves the full details of the leads that match the search criteria, including their current fields. If no query parameters are provided, then all leads will be returned.

Query Parameters:

* `email` (string, optional): Email for the lead you wish to retrieve (case insensitive)
* `start` (epoch timestamp integer, optional): Filter by lead `created_at >= start` — a static window over when the lead was first created.
* `end` (epoch timestamp integer, optional): Filter by lead `created_at <= end` — same static window as `start`.
* `last_activity_from` (epoch timestamp integer, optional): Filter by lead `last_activity_at >= last_activity_from` — a rolling window over the lead's most recent activity. A lead created months ago that engaged today will match a "today" filter; a lead with no activity since its creation will not.
* `last_activity_to` (epoch timestamp integer, optional): Filter by lead `last_activity_at <= last_activity_to` — same rolling semantics as `last_activity_from`.
* `start_after_id` (string, optional): Pagination cursor. The `id` of the last lead from the previous page; results begin after it.

All four time-based parameters accept Unix epoch seconds and are inclusive (`>=` / `<=`).

Pagination: Results are returned in pages of up to 1000 leads, ordered oldest-first. The response includes `has_more` (whether another page exists) and `last_id` (the `id` of the last lead in the page, or `null` if empty). To fetch the next page, repeat the request with `start_after_id` set to `last_id`, and keep going until `has_more` is `false`. All other query parameters must stay the same across pages.

Example Request & Success Response:

```json
GET https://api.spara.co/v1/leads/search?email=jane.doe@test.com&start=1749470400&end=1749492000
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json


Example Success Response (HTTP 200 OK):

{
  "object": "list",
  "data": [
    {
      "object": "lead",
      "id": "ABC12345",
      "created_at": "2025-06-09T12:00:00Z",
      "updated_at": "2025-06-09T15:15:00Z",
      "last_activity_at": "2025-06-09T15:15:00Z",
      "url": "https://app.spara.co/conversations/ABC12345",
      "data": {
        "email": "jane.doe@test.com",
        "first_name": "Jane",
        "last_name": "Doe",
        "employee_count": "50",
        "is_customer": "false",
        "is_interested": "true"
      },
      "conversation": {
        "created_at": "2025-06-09T12:00:00Z",
        "initial_url": "https://www.my-site.co/chat/jJyVt7TQ5",
        "messages": []
      },
      "calls": [
        {
          "started_at": "2025-12-12T16:56:47Z",
          "ended_at": "2025-12-12T16:59:30Z",
          "summary": "The lead called interested in purchasing...",
          "events": [],
          "data": {
            "is_interested": true
          },
          "post_call_classification": { "connection_outcome": "HUMAN" }
        }
      ]
    }
  ],
  "has_more": false,
  "last_id": "ABC12345"
}
```

**What Spara determined about each call.** Every call carries `post_call_classification`, Spara's verdict on who or what was on the line — `HUMAN`, `VOICEMAIL`, `IVR_ONLY`, `NO_ANSWER` and so on. **Read this in preference to inferring an outcome from call duration or from the transcript.** The verdict comes from a review that listens to the recording after the call, so it is the most accurate answer Spara has.

The values differ by direction. An outgoing call asks who picked up, so it can come back `VOICEMAIL` or `NO_ANSWER`; an incoming call asks what arrived, so it can come back `ABANDONED` (the caller hung up before saying anything) or `SPAM_ROBOCALL`. `HUMAN` and `UNCERTAIN` apply to both.

It is `null` on calls Spara has not reviewed — including incoming calls, whose review is still rolling out. `null` is not an outcome; it means no verdict exists. The review finishes a few seconds after the call ends, so a call fetched immediately may not have one yet. See [Webhooks](https://docs.spara.com/developers/spara-api/webhooks.md) for the full list of values and for the event that tells you when a verdict is ready.

#### Get Lead (GET)

This endpoint allows you to retrieve the current state of the lead's fields. This is useful for understanding the existing data before performing an update.

Endpoint: `/leads/{id}`

Method: `GET`

Description: Retrieves the full details of a specific lead, including their current fields.

Path Parameters:

* `id` (string, required): The unique identifier for the lead you wish to retrieve.

Example Request & Success Response:

```json
GET https://api.spara.co/v1/leads/ABC12345
Authorization: Bearer YOUR_API_KEY


Example Success Response (HTTP 200 OK):

{
  "object": "lead",
  "id": "ABC12345",
  "created_at": "2025-06-09T12:00:00Z",
  "updated_at": "2025-06-09T15:15:00Z",
  "url": "https://app.spara.co/conversations/ABC12345", // link to conversation
  "data": {
    "email": "jane.doe@test.com",
    "first_name": "Jane",
    "last_name": "Doe",
    "employee_count": 50,
    "is_customer": false
  },
    "conversation": {
    "created_at": "2025-06-09T12:00:00Z",
    "initial_url": "https://www.my-site.co/chat/jJyVt7TQ5",
    "messages": []
  },      
  "calls": [
    {
      "started_at": "2025-12-12T16:56:47Z",
      "ended_at": "2025-12-12T16:59:30Z",
      "summary": "The lead called interested in purchasing...",
      "events": [],
      "post_call_classification": { "connection_outcome": "HUMAN" }
    }
  ]
}
```

#### Create Lead (POST)

This endpoint allows you to create a new lead with or without pre-existing fields that you may have collected externally (e.g., from your CRM).

With **Sync API leads to your CRM** turned on, a lead created with an `email` is also pushed to your connected CRM.

Endpoint: `/leads`

Method: `POST`

Description: Create a new lead

Content-Type: `application/json`

Body: A JSON object containing the fields you wish to create for the lead

Example Request & Success Response:

```json
POST https://api.spara.co/v1/leads
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

{
  "first_name": "Jane",
  "last_name": "Doe",
  "num_employees": 53
}


Example Success Response (HTTP 200 OK):
{
  "object": "lead",
  "id": "ABC12345",
  "created_at": "2025-06-09T12:00:00Z",
  "updated_at": "2025-06-09T15:15:00Z",
  "url": "https://app.spara.co/conversations/ABC12345", // link to conversation
  "data": {
    "email": "jane.doe@test.com",
    "first_name": "Jane",
    "last_name": "Doe",
    "employee_count": 50,
    "is_customer": false
  },
    "conversation": {
    "created_at": "2025-06-09T12:00:00Z",
    "initial_url": "https://www.my-site.co/chat/jJyVt7TQ5",
    "messages": []
  },      
  "calls": [
    {
      "started_at": "2025-12-12T16:56:47Z",
      "ended_at": "2025-12-12T16:59:30Z",
      "summary": "The lead called interested in purchasing...",
      "events": []
    }
  ]
}
```

#### Update Lead (PATCH)

This endpoint allows you to enrich the lead by providing pre-existing fields that you may have collected externally (e.g., from your CRM).

With **Sync API leads to your CRM** turned on, changed fields are pushed to the lead's CRM record, and a lead with an email but no CRM record gets one.

Endpoint: `/leads/{id}`

Method: `PATCH`

Description: Update information on the lead

Path Parameters:

* `id` (string, required): The unique identifier for the lead you wish to update.

Content-Type: `application/json`

Body: A JSON object containing the fields you wish to update.

Example Request:

```json
PATCH https://api.spara.co/v1/leads/ABC12345
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json


{
  "first_name": "Jane",
  "last_name": "Doe",
  "num_employees": 53
}
```

A success response will return `200` without any additional data.

#### Call Lead (POST)

This endpoint triggers an outbound voice call to an existing lead using your Voice agent.

Endpoint: `/leads/{id}/call`

Method: `POST`

Description: Initiates an outbound call to the lead's phone number. The lead must have a phone number on record, and you specify the phone number to call *from* — that number acts as the caller ID and determines which Voice agent places the call. Spara resolves the published Voice agent assigned to that phone number automatically.

Path Parameters:

* `id` (string, required): The unique identifier for the lead to call.

Content-Type: `application/json`

Body:

* `from_number` (string, required): The phone number to place the call from, in E.164 format (e.g. `"+14155550123"`). This number must be one you've configured in Spara, and it must have a published Voice agent assigned to it. Spara uses it as the caller ID and routes the call through that agent.
* `call_mode` (string, optional): Either `"live"` (default) for a real call to the lead's phone, or `"qa"` for a test call. Use `"qa"` to dry-run the integration without dialing the lead's phone number.

Example Request:

```json
POST https://api.spara.co/v1/leads/ABC12345/call
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

{
  "from_number": "+14155550123"
}
```

A success response returns `200`. The response body includes the `voice_agent_id` Spara resolved from `from_number`, along with the `call_id` and initial `status`. The response is returned as soon as the call is queued — the actual call is placed asynchronously. To receive the call result (transcript, summary, recording, outcome), subscribe to the `Voice Call Ended` event on your webhook endpoint. See [Webhooks](https://docs.spara.com/developers/spara-api/webhooks.md) for the event schema.

Error responses specific to this endpoint:

* `400 Bad Request`: The lead has no phone number set, the lead's or the `from_number` value can't be parsed, or the `from_number` has no published Voice agent assigned.
* `404 Not Found`: The lead was not found, or the `from_number` is not a phone number configured in your account.

{% hint style="info" %}
**Concurrency limit.** Outbound calls are subject to a cap of **5 calls per second**. A dedicated per-account version of this cap ships by June 2026. For most use cases this is well above your actual call rate. If you anticipate bursty or high-volume dialing (large batch sends, telemarketing-style campaigns), contact your Spara representative ahead of time so we can confirm headroom.
{% endhint %}

{% hint style="warning" %}
Do not orchestrate the same Voice agent through both this API and a Spara Workflow simultaneously. Pick one system to own the call cadence — splitting workflow logic across both creates coordination overhead and makes call behavior hard to reason about. If your external workflow tool drives the cadence, use this API and disable any equivalent [Call Phone Step](https://docs.spara.com/build/workflows/steps/call-phone) in Spara Workflows.
{% endhint %}

### Rate Limiting

To ensure fair usage and system stability, API requests are subject to rate limits. If you exceed the allocated rate limits, your requests will be temporarily blocked, and you will receive an `HTTP 429 Too Many Requests` status code.

Requests are limited to **10 per API key per minute**. If you need higher throughput, spread work across multiple API keys or move to [Webhooks](https://docs.spara.com/developers/spara-api/webhooks.md) for a continuous stream instead of polling. See [Webhook, Web API, or Workflow API Step?](https://docs.spara.com/developers/spara-api/webhook-web-api-or-workflow-api-step.md).

Responses are limited to a maximum of **1,000 leads per request**. In order to get more than 1,000 leads, you will need to make multiple requests.

Outbound calls placed via [#call-lead-post](#call-lead-post "mention") are subject to a separate concurrency cap of **5 calls per second**. A dedicated per-account version of this cap ships by June 2026.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.spara.com/developers/spara-api/web-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
