> For the complete documentation index, see [llms.txt](https://docs.useagentex.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.useagentex.com/api-reference/errors.md).

# Error Codes

All errors from the Agentex API follow a consistent structure:

```json
{
  "error": {
    "code": "credential_expired",
    "message": "Your subscription credential for this listing expired on 2025-04-10.",
    "status": 403
  }
}
```

***

## Authentication errors

| HTTP Status | Code                | Description                                           |
| ----------- | ------------------- | ----------------------------------------------------- |
| 401         | `unauthorized`      | No `Authorization` header was provided                |
| 401         | `invalid_api_key`   | The API key is invalid or has been revoked            |
| 401         | `jwt_expired`       | The wallet-signature JWT has expired; re-authenticate |
| 401         | `invalid_signature` | The wallet signature could not be verified            |

***

## Access and credential errors

| HTTP Status | Code                   | Description                                                          |
| ----------- | ---------------------- | -------------------------------------------------------------------- |
| 403         | `credential_not_found` | Your wallet does not hold a rental credential for this listing       |
| 403         | `credential_expired`   | Your subscription credential has passed its expiry slot              |
| 403         | `insufficient_balance` | Your Per-Task balance for this listing is zero                       |
| 403         | `listing_paused`       | The creator has paused the listing; no task executions are permitted |

***

## Request errors

| HTTP Status | Code                 | Description                                                |
| ----------- | -------------------- | ---------------------------------------------------------- |
| 400         | `invalid_request`    | The request body is malformed or missing required fields   |
| 400         | `invalid_listing_id` | The `listing_id` (as `agent_id`) format is invalid         |
| 404         | `listing_not_found`  | No listing exists with this ID, or it has been unpublished |

***

## Rate limiting

| HTTP Status | Code                  | Description                                        |
| ----------- | --------------------- | -------------------------------------------------- |
| 429         | `rate_limit_exceeded` | You have exceeded the rate limit for this endpoint |

When rate-limited, the response includes a `Retry-After` header with the number of seconds to wait before retrying. The Agentex SDK surfaces this as `retryAfter` on `AgentexRateLimitError`.

***

## Server errors

| HTTP Status | Code                  | Description                                                   |
| ----------- | --------------------- | ------------------------------------------------------------- |
| 500         | `internal_error`      | An unexpected error occurred; retry the request               |
| 503         | `service_unavailable` | The service is temporarily unavailable; check the status page |

Transient errors (500, 503) should be retried with exponential backoff. The `run_id` in successful execution responses and the request ID in error responses can be provided to support to help diagnose issues.

***

## On-chain errors

Errors originating from the Solana on-chain program are surfaced via the API with appropriate HTTP status codes. The raw Anchor error code is included in the error detail for debugging:

```json
{
  "error": {
    "code": "credential_not_found",
    "message": "No rental credential found for this wallet and listing.",
    "status": 403,
    "on_chain_error": {
      "program": "agentex_marketplace",
      "anchor_code": 6001
    }
  }
}
```

The `agentex_marketplace` program defines 16 error codes. The ones most likely to surface through the API are listed above; the full set (including creator- and protocol-level errors such as `FeeTooHigh` or `ProtocolPaused`) is documented in [On-chain program](/protocol/on-chain-program.md).

| Anchor Code | Name                       |
| ----------- | -------------------------- |
| 6000        | `ListingNotActive`         |
| 6001        | `CredentialNotFound`       |
| 6002        | `CredentialExpired`        |
| 6003        | `InsufficientBalance`      |
| 6004        | `Unauthorized`             |
| 6005        | `InvalidAccessType`        |
| 6006        | `CredentialRevoked`        |
| 6007        | `WithdrawalExceedsBalance` |
| 6008        | `FeeTooHigh`               |
| 6009        | `PriceTooLow`              |
| 6010        | `MetadataUriTooLong`       |
| 6011        | `InvalidDuration`          |
| 6012        | `DepositTooLow`            |
| 6013        | `ProtocolPaused`           |
| 6014        | `ArithmeticOverflow`       |
| 6015        | `EscrowNotEmpty`           |
| 6016        | `NothingToWithdraw`        |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.useagentex.com/api-reference/errors.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
