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

# Introduction

Welcome to the Dashlink API documentation. This guide will help you integrate Dashlink's powerful link management features into your application.

## Getting Started

To get started with the Dashlink API, you'll need to understand the base URL structure. All API requests are made to a base URL, and individual endpoints are appended to this base URL.

### Base URL

The base URL is the root address for all Dashlink API endpoints. All API requests must be made to this base URL, followed by the specific endpoint path.

```bash Production Base URL theme={null}
https://dashlink.ai
```

The base URL serves as the foundation for all API interactions. When making requests, you'll append the specific endpoint path to this base URL. For example, to access the get shortlinks endpoint, you would use:

```bash API Endpoint theme={null}
https://dashlink.ai/api/v1/shortlinks/get_shortlinks
```

<Note>
  All API endpoints in this documentation are relative to the base URL. When you see an endpoint like `/api/v1/links`, it should be appended to the base URL to form the complete request URL.
</Note>

### Authentication

All API requests to the Dashlink API require authentication using an API key. You can generate your API key from the Dashlink app dashboard.

To authenticate your requests, include the `X-API-Key` header in all API calls with your API key as the value.

```bash API Request Header theme={null}
X-API-Key: dlk_live_••••••
```

Here is the example of how your request have send the auth header:

```bash cURL theme={null}
curl --location 'https://dashlink.ai/api/v1/shortlinks/get_shortlinks' \
--header 'X-API-Key: dlk_live_••••••'
```

<Warning>
  Keep your API key secure and never expose it in client-side code or public repositories. Treat your API key as a password.
</Warning>

### Error Handling

The Dashlink API returns errors in a consistent format using standard HTTP status codes. All error responses follow the same structure, making it easy to handle errors in your application.

Here is the example of how error response schema looks like:

```json Error Response theme={null}
{
    "error": {
        "message": "You must be logged in or provide a valid API key to access this resource.",
        "status_code": 401,
        "code": "AUTHENTICATION_REQUIRED"
    }
}
```

**Common HTTP Status Codes:**

| Status Code                   | Description                                                |
| ----------------------------- | ---------------------------------------------------------- |
| 200 **OK**                    | The request was successful                                 |
| 201 **Created**               | The resource was successfully created                      |
| 400 **Bad Request**           | The request was invalid or malformed                       |
| 401 **Unauthorized**          | Authentication required or invalid API key                 |
| 403 **Forbidden**             | You don't have permission to access this resource          |
| 404 **Not Found**             | The requested resource does not exist                      |
| 422 **Unprocessable Entity**  | The request was well-formed but contains validation errors |
| 429 **Too Many Requests**     | Rate limit exceeded                                        |
| 500 **Internal Server Error** | An unexpected error occurred on the server                 |

<Note>
  Always check the `status_code` and `code` fields in the error response to handle different error scenarios appropriately in your application.
</Note>

### Pagination & Sorting

All listing APIs in the Dashlink API support pagination and sorting to help you efficiently retrieve and organize data.

**Pagination Parameters:**

* `page` - The page number to retrieve (default: 1)
* `per_page` - Number of items per page (default: 10)
* `sort_by` - Field to sort by (e.g., `most_recent`, `created_at`, `updated_at`)
* `order` - Sort order: `asc` for ascending or `desc` for descending (default: `desc`)

**Example Request with Pagination:**

```bash cURL theme={null}
curl --location 'https://dashlink.ai/api/v1/shortlinks/get_shortlinks?page=1&per_page=10&sort_by=most_recent&order=desc' \
--header 'X-API-Key: dlk_live_••••••'
```

<Info>
  The pagination parameters can be combined to customize how you retrieve data. For example, you can sort by creation date in descending order and retrieve 20 items per page.
</Info>
