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

# API Development

> Learn how to preview changes locally

<Info>
  The base URL to send all API requests is `https://betaapi.audiohook.com/v2/companies/:companyUUID`. HTTPS is required for all API requests.

  The Audiohook API follows RESTful conventions when possible, with most operations performed via `GET`, `POST`, `PATCH`, and `DELETE`. Response bodies are encoded as JSON.
</Info>

### Authorization

<Info>
  The API uses token-based authentication.\
  Users need to sign in at [https://app.audiohook.com/login](https://app.audiohook.com/login) to get a valid JWT token, which is then passed to the API in the `Authorization` header.
</Info>

Send the JWT token in the Authorization header of all your requests:

```
Authorization: Bearer $JWT_TOKEN
```

To use client ID and secret:

* Send a `POST` request to [/get-token](https://audiohook.github.io/ah-slate/#get-token)
* Receive a JWT token valid for 1 hour
* Use it in `Authorization` header

***

## Authenticate

### Request Example

<CodeGroup>
  ```shell theme={null}
  curl -X POST https://betaapi.audiohook.com/v2/authenticate \
    -H "Authorization: Bearer ${API_TOKEN}" \
    -H "Content-Type: application/json" \
    -d '{
      "request_headers": [
        {
          "name": "X-Request-Header",
          "value": "Header value"
        }
      ],
      "body": {
        "token": "zsZymXaVNJmOlaNfZVuZhltSqPMEy-YcDcdLf48tRFNJ",
        "type": "oauth"
      }
    }'
  ```
</CodeGroup>

### Response Sample

<CodeGroup>
  ```json theme={null}
  {
    "Message": "",
    "type": "success",
    "_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6Imp3ay10ZXN0L...",
    "user": {
      "name": {
        "first_name": "",
        "middle_name": "",
        "last_name": ""
      },
      "user_id": "user-live-404decf62",
      "emails": [
        {
          "email": "example@audiohook.com",
          "verified": true
        }
      ],
      "providers": [
        {
          "provider_type": "Google",
          "profile_picture_url": "https://lh3.googleusercontent.com/a/..."
        }
      ],
      "created_at": "2023-03-16T20:48:41+00:00",
      "status": "active"
    }
  }
  ```
</CodeGroup>

🔁 `POST /v2/authenticate` returns user data and a valid token.
