# Build your own integration


# Build your own integration

AutoUncle CoDriver follows up on a car dealer's leads around the clock. Your system can send those leads in, read what became of them, and hear about everything that happens next: new opportunities, customer replies, booked appointments, won and lost deals.

Everything is built on standards you already know, so you can use off-the-shelf tools:

| What | Standard |
|---|---|
| Authentication | OAuth 2.1 client credentials, JWT access tokens |
| API contract | [OpenAPI 3.1](/openapi.yaml), JSON Schema 2020-12 |
| Errors | RFC 9457 problem details (`application/problem+json`) |
| Safe retries | `Idempotency-Key` header (IETF draft) |
| Rate limits | `RateLimit` / `RateLimit-Policy` headers (IETF draft), `429` + `Retry-After` |
| Events | CloudEvents 1.0, delivered as [Standard Webhooks](https://www.standardwebhooks.com) |

**Building with an AI coding agent?** Give it the [agent kit](/developers/agent-kit): one skill that walks it through the whole integration.

## Quick start: your first lead in five minutes

You need an owner or admin login for the dealer's AutoUncle CoDriver organization. Build in a **sandbox organization** (ask your AutoUncle contact for one): it is in safe mode, so nothing you push reaches a customer, the dealer's CRM or a sales rep. A test lead is only a label and is otherwise processed in full, so in a live organization it would reach the customer, the dealer's CRM and the sales reps (see [Testing](/developers/testing)).

**1. Create an API lead source.** Settings → Lead sources → Create lead source, type *API*. Copy its ID (`src_…`) from Settings → Developers → API lead sources.

**2. Create an API client.** Settings → Developers → Create application. Pick *Two-way integration* and tick *Test client* while you build. Copy the client ID and secret.

**3. Get a token.**

```bash
TOKEN=$(curl -s -X POST https://codriver.autouncle.com/oauth/token \
  -u "$CLIENT_ID:$CLIENT_SECRET" \
  --data-urlencode "grant_type=client_credentials" \
  --data-urlencode "scope=leads_write leads_read opportunities_read events_read" | jq -r .access_token)
```

**4. Push a lead.**

```bash
curl -s -X POST https://codriver.autouncle.com/api/v1/leads \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "lead_source_id": "src_019535d9-3df7-79fb-b466-fa907fa17f9e",
    "email": "anna@example.com",
    "name": "Anna Jensen",
    "message": "Is the Golf still for sale?",
    "external_reference": { "system": "my-crm", "id": "4711" }
  }'
```

AutoUncle CoDriver answers `202 Accepted` with the lead's ID and a `status_url`.

**5. Read what became of it.** `GET` the `status_url`: within seconds the lead is `processed` and has an `opportunity_id`.

Then go further:

- [Push leads](/developers/leads): every field, idempotency, your own references, test leads.
- [Read data](/developers/reading): lead status, opportunities, appointments.
- [Webhooks](/developers/webhooks): receive every event the moment it happens.
- [Events feed](/developers/events-feed): poll the same events if you can't receive webhooks.
- [Testing](/developers/testing): Test clients, test leads, test events.

The complete reference is the [OpenAPI specification](/api-docs).
