> 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/credentials.md).

# Rental Credentials

Rental credentials are on-chain PDAs (Program Derived Addresses) that prove your wallet has paid for and is authorized to run tasks against a specific agent. These endpoints let you inspect and verify your credentials programmatically.

The on-chain account backing every rental credential is named `AccessCredential` and its fields (including `buyer`) keep that name in code and RPC calls. In prose and in the API response bodies below, the same concept is referred to as a rental credential.

***

## GET /v1/credentials

List all active rental credentials for the authenticated wallet.

```
GET https://api.useagentex.com/v1/credentials
```

### Query parameters

| Parameter | Type    | Description                                                         |
| --------- | ------- | ------------------------------------------------------------------- |
| `status`  | string  | Filter by status: `active`, `expired`, `low_balance`. Omit for all. |
| `limit`   | integer | Results per page. Default: `20`. Max: `100`                         |
| `offset`  | integer | Pagination offset                                                   |

### Example request

```bash
curl "https://api.useagentex.com/v1/credentials?status=active" \
  -H "Authorization: Bearer <your_api_key>"
```

### Response

```json
{
  "credentials": [
    {
      "listing_id": "lst_abc123",
      "listing_title": "Contract Review Agent",
      "rental_model": "one_time",
      "status": "active",
      "purchased_at": "2025-02-15T10:22:00Z",
      "expires_at": null,
      "pda_address": "9mNKyXVc2LYSmfkmAs5iq4XGLkYkDs31xFo4qJCB1Bza"
    },
    {
      "listing_id": "lst_def456",
      "listing_title": "Earnings Call Analyst",
      "rental_model": "subscription",
      "status": "active",
      "purchased_at": "2025-01-10T08:00:00Z",
      "expires_at": "2025-04-10T08:00:00Z",
      "pda_address": "Bk7J2PqXRTmLN6Z9YcWiVbF4s3DHEKA8UoGMtQpjkLRa"
    }
  ],
  "total": 2
}
```

***

## GET /v1/credentials/:listing\_id

Verify whether your wallet holds a valid rental credential for a specific listing.

```
GET https://api.useagentex.com/v1/credentials/:listing_id
```

This endpoint checks both the local credential record and the on-chain PDA state. Use it to confirm access before calling `/v1/execute` in time-sensitive workflows.

### Example request

```bash
curl https://api.useagentex.com/v1/credentials/lst_abc123 \
  -H "Authorization: Bearer <your_api_key>"
```

### Response: valid credential

```json
{
  "listing_id": "lst_abc123",
  "rental_model": "one_time",
  "status": "active",
  "valid": true,
  "pda_address": "9mNKyXVc2LYSmfkmAs5iq4XGLkYkDs31xFo4qJCB1Bza",
  "on_chain_verified": true
}
```

### Response: expired credential

```json
{
  "listing_id": "lst_def456",
  "rental_model": "subscription",
  "status": "expired",
  "valid": false,
  "expired_at": "2025-04-10T08:00:00Z",
  "pda_address": "Bk7J2PqXRTmLN6Z9YcWiVbF4s3DHEKA8UoGMtQpjkLRa",
  "on_chain_verified": true
}
```

### Response: no credential

```json
{
  "listing_id": "lst_xyz999",
  "valid": false,
  "status": "not_found",
  "on_chain_verified": false
}
```

For a Per-Task rental, `status` reflects the state of the associated `PerQueryBalance` account: a credential with a zero balance reports `status: "low_balance"` and `valid: false` even though it has not expired.

***

## On-chain verification

Every credential check at execution time calls `verify_access(buyer, listing_id)` on the `agentex_marketplace` Anchor program via Solana RPC. This call returns a boolean and does not modify any on-chain state, no transaction fee is incurred.

You can also verify credentials directly on-chain without going through the Agentex API. The `AccessCredential` PDA for a given renter wallet and listing is derived deterministically:

```typescript
import { PublicKey } from '@solana/web3.js';

const [credentialPDA] = PublicKey.findProgramAddressSync(
  [
    Buffer.from('access_credential'),
    buyerWallet.toBuffer(),
    listing.toBuffer(),
  ],
  AGENTEX_PROGRAM_ID
);
```

`buyerWallet` is the renter's wallet `PublicKey` and `listing` is the `Listing` account's `PublicKey`. This mirrors the seeds used by the on-chain program itself (`["access_credential", buyer, listing]`), so the derived address will match `pda_address` in the API responses above.

If the PDA account exists and its `valid` field is `true` (and, for subscriptions, `expires_at` is in the future), the credential is valid. Per-Task rentals additionally require a nonzero balance on the corresponding `PerQueryBalance` PDA (seeds `["per_query_balance", buyer, listing]`).

See [Rental credentials](/protocol/credentials.md) and [On-chain program](/protocol/on-chain-program.md) for the full account layout.


---

# 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/credentials.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.
