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

# API Reference

> Integrate with the SendPilot External API

The SendPilot API enables you to programmatically manage LinkedIn outreach campaigns, add leads, update lead statuses, send messages, and receive real-time webhook notifications.

## Base URL

```
https://api.sendpilot.ai/v1
```

## Authentication

All API requests require authentication using an API key header. Include the following header in every request:

```bash theme={null}
X-API-Key: YOUR_API_KEY
```

### Example Request

```bash theme={null}
curl -X GET https://api.sendpilot.ai/v1/campaigns \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json"
```

<Warning>
  Keep your API key secret. Never commit it to version control or expose it in client-side code.
</Warning>

## Error Handling

The API uses standard HTTP status codes and returns structured error responses:

```json theme={null}
{
  "statusCode": 400,
  "message": "Validation failed",
  "error": "Bad Request"
}
```

### Common Status Codes

| Code  | Description                               |
| ----- | ----------------------------------------- |
| `200` | Success                                   |
| `201` | Created                                   |
| `400` | Bad request (invalid payload)             |
| `401` | Unauthorized (invalid or missing API key) |
| `403` | Forbidden (insufficient permissions)      |
| `404` | Resource not found                        |
| `500` | Internal server error                     |

## Webhooks

SendPilot sends real-time notifications to your webhook endpoints for various events:

**Message Events:**

* `message.sent` - When a message is sent to a lead
* `message.received` - When a lead replies to your message

**Connection Events:**

* `connection.sent` - When a connection request is sent
* `connection.accepted` - When a connection request is accepted

**Campaign Events:**

* `campaign.started` - When a campaign starts
* `campaign.paused` - When a campaign is paused
* `campaign.resumed` - When a campaign is resumed

**Lead Events:**

* `lead.status.changed` - When a lead's status changes

Learn more in our [Webhooks documentation](/webhooks/overview).

## Getting Started

<Steps>
  <Step title="Get Your API Key">
    Navigate to Integrations → API Keys in the SendPilot dashboard and create a new API key.
  </Step>

  <Step title="Make Your First Request">
    Test your API key by listing your campaigns:

    ```bash theme={null}
    curl https://api.sendpilot.ai/v1/campaigns \
      -H "X-API-Key: YOUR_API_KEY"
    ```
  </Step>

  <Step title="Set Up Webhooks">
    Configure webhook subscriptions in the dashboard to receive real-time event notifications.
  </Step>
</Steps>
