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

# Errors

> Learn about the error codes the Dub Partner API returns and how to fix them.

When a request fails, the Dub Partner API returns an HTTP status code and a JSON body with a machine-readable error code, a human-readable message, a link to the docs and the request ID:

```json theme={null}
{
  "error": {
    "code": "forbidden",
    "message": "Missing required scopes: payouts.read.",
    "doc_url": "https://dub.co/docs/api-reference/errors#forbidden",
    "request_id": "req_1KQ7YX7Z3H5T0A2B4C6D8E9F0G"
  }
}
```

The `request_id` matches the `Dub-Request-Id` response header. Include it when you contact support about a specific request.

## Error codes

> [accordion] bad\_request
>
> 400
>
> * **Problem:** The `Authorization` header doesn't start with `Bearer `, the `Dub-Version` header isn't a valid version, or `sortBy=saleAmount` is sent without a `programId` for a program that shares revenue with you.
> * **Solution:** Check that the request is properly formatted.

> [accordion] unauthorized
>
> 401
>
> * **Problem:** The API key is missing, invalid, or expired.
> * **Solution:** Make sure you are using a valid partner API key. See [Authentication](https://dub.co/docs/partner-api-reference/authentication.md).

> [accordion] forbidden
>
> 403
>
> * **Problem:** The API key is missing a required [scope](https://dub.co/docs/partner-api-reference/authentication.md#scopes), the partner account isn't approved in the Dub Partner Network, a large program doesn't list its customers to you yet, or you can't message the program on `POST /messages`.
> * **Solution:** Add the scopes named in the error message to your API key, or [apply to the Dub Partner Network](https://dub.co/help/article/program-marketplace.md#joining-the-dub-partner-network). You can message programs you're enrolled in that have messaging turned on, and programs that have messaged you.

> [accordion] not\_found
>
> 404
>
> * **Problem:** The `programId` you passed is a program you aren't enrolled in, or Dub's network program on `GET /commissions`.
> * **Solution:** Use the ID of a program you're enrolled in. See [List programs](https://dub.co/docs/partner-api-reference/programs/list.md).

> [accordion] unprocessable\_entity
>
> 422
>
> * **Problem:** A query parameter is invalid, `startingAfter` and `endingBefore` were both sent, or a pagination ID doesn't exist, belongs to another partner, or is outside the `programId` you passed.
> * **Solution:** Read the error message, which names the invalid field, and fix that value. See [Pagination](https://dub.co/docs/partner-api-reference/introduction.md#pagination).

> [accordion] rate\_limit\_exceeded
>
> 429
>
> * **Problem:** You have sent too many requests in a given amount of time.
> * **Solution:** Wait for the number of seconds in the `Retry-After` header, then try again. See [Rate limits](https://dub.co/docs/partner-api-reference/rate-limits.md).

> [accordion] internal\_server\_error
>
> 500
>
> * **Problem:** Something went wrong on Dub's side.
> * **Solution:** Try again later. If the problem persists, [contact support](https://dub.co/contact/support) with the request ID.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.