> ## Documentation Index
> Fetch the complete documentation index at: https://docs.demomatic.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# Domain Leads

> Retrieve all CTA form submissions across every video in a domain, ordered most-recent-first.

Returns all CTA form submissions collected across every video in the specified domain, sorted from newest to oldest.

<Note>
  This endpoint aggregates leads from all videos in the domain. To retrieve leads for a single video, use `GET /v1/videos/:id/leads`.
</Note>

## Endpoint

```
GET /v1/domains/:domain_id/leads
```

## Authentication

<ParamField header="Authorization" type="string" required>
  Bearer token. Pass your API key: `Authorization: Bearer <api_key>`
</ParamField>

## Path parameters

<ParamField path="domain_id" type="number" required>
  The numeric ID of the domain. Retrieve domain IDs from `GET /v1/domains`.
</ParamField>

## Response

<ResponseField name="data" type="object" required>
  <Expandable title="properties" defaultOpen>
    <ResponseField name="leads" type="object[]" required>
      Array of lead objects ordered most-recent-first.

      <Expandable title="lead properties">
        <ResponseField name="id" type="number" required>
          Unique identifier for the lead submission.
        </ResponseField>

        <ResponseField name="video_id" type="number" required>
          ID of the video the lead was submitted from.
        </ResponseField>

        <ResponseField name="response_data" type="object" required>
          Key-value pairs captured from the CTA form. The exact fields depend on your domain's CTA configuration.
        </ResponseField>

        <ResponseField name="submitted_at" type="string" required>
          ISO 8601 timestamp of when the form was submitted.
        </ResponseField>

        <ResponseField name="internal_name" type="string" required>
          Internal name of the video the lead came from.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

## Error responses

| Status            | Condition                                                 |
| ----------------- | --------------------------------------------------------- |
| `400 Bad Request` | `domain_id` is not a valid number.                        |
| `404 Not Found`   | Domain does not exist or does not belong to your account. |

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url https://api.demomatic.tech/v1/domains/45/leads \
    --header "Authorization: Bearer YOUR_API_KEY"
  ```

  ```javascript JavaScript theme={null}
  const domainId = 45;

  const response = await fetch(
    `https://api.demomatic.tech/v1/domains/${domainId}/leads`,
    {
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
      },
    }
  );

  const { data } = await response.json();
  console.log(data.leads);
  ```
</CodeGroup>

### Response

```json 200 theme={null}
{
  "data": {
    "leads": [
      {
        "id": 101,
        "video_id": 7,
        "response_data": {
          "name": "Bob Jones",
          "email": "bob@example.com",
          "company": "Widgets Inc"
        },
        "submitted_at": "2024-01-20T14:22:00.000Z",
        "internal_name": "Feature Demo - Jan 2024"
      }
    ]
  }
}
```
