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

# Directify API Authentication with Sanctum Tokens

> Authenticate requests to the Directify REST API using Laravel Sanctum personal access tokens — generate, scope, rotate, and revoke from your account.

## Authentication

All API endpoints require authentication using Laravel Sanctum. Include your API token in the Authorization header:

```bash theme={null}
Authorization: Bearer YOUR_API_TOKEN
```

<Tip>
  To get your API token, go to your Directify dashboard and click on **Settings → API**. Then click on the **"Key" icon** to generate a new token and copy it.
</Tip>

## Base URL

```
https://directify.app/api
```

## Rate Limiting

API requests are limited to **120 requests per minute** per directory. This limit is designed to support automated workflows, including LLM-powered integrations that manage listings programmatically.

If you exceed the rate limit, the API returns a `429 Too Many Requests` response. Implement exponential backoff and retry logic to handle this gracefully.

## Error Responses

### Validation Errors

When request validation fails, the API returns a 422 status code with validation error details:

```json theme={null}
{
  "message": "The given data was invalid.",
  "errors": {
    "url": [
      "The url field is required."
    ],
    "category_id": [
      "The selected category id is invalid."
    ]
  }
}
```

### Authentication Errors

When authentication fails, the API returns a 401 status code:

```json theme={null}
{
  "message": "Unauthenticated."
}
```

### Authorization Errors

When the user doesn't have access to a directory, the API returns a 403 status code:

```json theme={null}
{
  "message": "You do not own this directory"
}
```

### Not Found Errors

When a resource is not found, the API returns a 404 status code:

```json theme={null}
{
  "message": "No query results for model [App\\Models\\Project] 123"
}
```

## Best Practices

1. **Always check if a listing exists** before creating a new one using the `/exists` endpoint
2. **Use pagination** when retrieving large lists of listings
3. **Include custom field values** in your listing creation/update requests
4. **Validate category and tag IDs** before sending them in requests
5. **Handle rate limiting** by implementing exponential backoff for failed requests
6. **Cache directory metadata** like categories, tags, and custom fields to reduce API calls
