# x402 resources

Per-call resources an agent pays for over the x402 rail.

## List your registered resources

`GET /v1/x402/resources`

### Responses

#### `200`: This merchant's resources.

Body (`application/json`):

- `resources` `object[]` _(required)_
  - `id` `string` _(required)_
  - `merchantId` `string` _(required)_
  - `url` `string` _(required)_
  - `description` `string`
  - `mimeType` `string`
  - `price` `object` _(required)_
    - `amount` `string` _(required)_: Exact minor units. Calculate with this value.
    - `asset` `string` _(required)_: ISO asset code, e.g. IDR, USD, USDC.
    - `formatted` `string` _(required)_: Machine decimal; ungrouped and dot-separated.
    - `display` `string` _(required)_: Localized display text. Never parse this value.
  - `maxTimeoutSeconds` `integer` _(required)_
  - `listed` `boolean` _(required)_: Whether it appears in the public x402 resource index.
  - `accepts` `object[]` _(required)_
    - `chain` `string` _(required)_
    - `asset` `string` _(required)_
    - `contract` `string` _(required)_
    - `payTo` `string` _(required)_
    - `transferMethod` `string` _(required)_
    - `domain` `object` _(required)_

#### `401`: Missing or unknown API key.

Body (`application/json`):

- `error` `object` _(required)_
  - `code` `string` _(required)_
  - `message` `string` _(required)_
  - `retryable` `boolean` _(required)_
  - `details` `object`

### Example request

```bash
curl https://api.mayarin.xyz/v1/x402/resources
```

```ts
fetch('https://api.mayarin.xyz/v1/x402/resources')
```

## Register a resource

`POST /v1/x402/resources`

Register or re-register an endpoint this merchant hosts, so Mayarin can quote it and settle for it. The `url` must be the exact URL an agent will call — scheme, host and path all count, because a resource is identified by it. The token's EIP-712 domain and transfer method are read off the contracts at registration, never entered.

### Header parameters

- `Idempotency-Key` `string` _(required)_: Stable unique key for this logical write. Keep it unchanged when retrying.

### Request body (`application/json`)

- `id` `string` _(required)_
- `url` `string <uri>` _(required)_
- `description` `string`
- `mimeType` `string`
- `price` `object` _(required)_
  - `amount` `string` _(required)_
  - `asset` `string` _(required)_
- `accepts` `object[]` _(required)_
  - `chain` `string` _(required)_
  - `asset` `string` _(required)_
  - `contract` `string` _(required)_
  - `payTo` `string` _(required)_
- `maxTimeoutSeconds` `integer` _(required)_
- `listed` `boolean`

### Responses

#### `201`: Registered resource.

Body (`application/json`):

- `resource` `object` _(required)_
  - `id` `string` _(required)_
  - `merchantId` `string` _(required)_
  - `url` `string` _(required)_
  - `description` `string`
  - `mimeType` `string`
  - `price` `object` _(required)_
    - `amount` `string` _(required)_: Exact minor units. Calculate with this value.
    - `asset` `string` _(required)_: ISO asset code, e.g. IDR, USD, USDC.
    - `formatted` `string` _(required)_: Machine decimal; ungrouped and dot-separated.
    - `display` `string` _(required)_: Localized display text. Never parse this value.
  - `maxTimeoutSeconds` `integer` _(required)_
  - `listed` `boolean` _(required)_: Whether it appears in the public x402 resource index.
  - `accepts` `object[]` _(required)_
    - `chain` `string` _(required)_
    - `asset` `string` _(required)_
    - `contract` `string` _(required)_
    - `payTo` `string` _(required)_
    - `transferMethod` `string` _(required)_
    - `domain` `object` _(required)_

#### `400`: Validation error, or a rail this deployment refuses.

Body (`application/json`):

- `error` `object` _(required)_
  - `code` `string` _(required)_
  - `message` `string` _(required)_
  - `retryable` `boolean` _(required)_
  - `details` `object`

#### `401`: Missing or unknown API key.

Body (`application/json`):

- `error` `object` _(required)_
  - `code` `string` _(required)_
  - `message` `string` _(required)_
  - `retryable` `boolean` _(required)_
  - `details` `object`

### Example request

```bash
curl https://api.mayarin.xyz/v1/x402/resources \
  --request POST \
  --header 'Idempotency-Key: string' \
  --header 'Content-Type: application/json' \
  --data '{
  "id": "string",
  "url": "string",
  "description": "string",
  "mimeType": "string",
  "price": {
    "amount": "string",
    "asset": "IDR"
  },
  "accepts": [
    {
      "chain": "ethereum",
      "asset": "IDR",
      "contract": "string",
      "payTo": "string"
    }
  ],
  "maxTimeoutSeconds": 0,
  "listed": true
}'
```

```ts
fetch('https://api.mayarin.xyz/v1/x402/resources', {
  method: 'POST',
  headers: {
    'Idempotency-Key': 'string',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    id: 'string',
    url: 'string',
    description: 'string',
    mimeType: 'string',
    price: {
      amount: 'string',
      asset: 'IDR'
    },
    accepts: [
      {
        chain: 'ethereum',
        asset: 'IDR',
        contract: 'string',
        payTo: 'string'
      }
    ],
    maxTimeoutSeconds: 0,
    listed: true
  })
})
```

## Remove a resource

`DELETE /v1/x402/resources/{id}`

Stops offering the `402`. Nothing already paid is undone.

### Path parameters

- `id` `string` _(required)_

### Responses

#### `204`: Removed.

#### `404`: No resource with that id, or not this merchant's.

Body (`application/json`):

- `error` `object` _(required)_
  - `code` `string` _(required)_
  - `message` `string` _(required)_
  - `retryable` `boolean` _(required)_
  - `details` `object`

### Example request

```bash
curl https://api.mayarin.xyz/v1/x402/resources/string \
  --request DELETE
```

```ts
fetch('https://api.mayarin.xyz/v1/x402/resources/string', {
  method: 'DELETE'
})
```

## List a resource in the public index

`POST /v1/x402/resources/{id}/list`

Opts the resource into the public cross-merchant x402 index. The resource stays sellable by URL either way; listing only decides whether an agent browsing the index is shown it.

### Path parameters

- `id` `string` _(required)_

### Responses

#### `200`: Listed resource.

Body (`application/json`):

- `id` `string` _(required)_
- `merchantId` `string` _(required)_
- `url` `string` _(required)_
- `description` `string`
- `mimeType` `string`
- `price` `object` _(required)_
  - `amount` `string` _(required)_: Exact minor units. Calculate with this value.
  - `asset` `string` _(required)_: ISO asset code, e.g. IDR, USD, USDC.
  - `formatted` `string` _(required)_: Machine decimal; ungrouped and dot-separated.
  - `display` `string` _(required)_: Localized display text. Never parse this value.
- `maxTimeoutSeconds` `integer` _(required)_
- `listed` `boolean` _(required)_: Whether it appears in the public x402 resource index.
- `accepts` `object[]` _(required)_
  - `chain` `string` _(required)_
  - `asset` `string` _(required)_
  - `contract` `string` _(required)_
  - `payTo` `string` _(required)_
  - `transferMethod` `string` _(required)_
  - `domain` `object` _(required)_

#### `404`: No resource with that id, or not this merchant's.

Body (`application/json`):

- `error` `object` _(required)_
  - `code` `string` _(required)_
  - `message` `string` _(required)_
  - `retryable` `boolean` _(required)_
  - `details` `object`

### Example request

```bash
curl https://api.mayarin.xyz/v1/x402/resources/string/list \
  --request POST
```

```ts
fetch('https://api.mayarin.xyz/v1/x402/resources/string/list', {
  method: 'POST'
})
```

## Remove a resource from the public index

`POST /v1/x402/resources/{id}/unlist`

### Path parameters

- `id` `string` _(required)_

### Responses

#### `200`: Unlisted resource.

Body (`application/json`):

- `id` `string` _(required)_
- `merchantId` `string` _(required)_
- `url` `string` _(required)_
- `description` `string`
- `mimeType` `string`
- `price` `object` _(required)_
  - `amount` `string` _(required)_: Exact minor units. Calculate with this value.
  - `asset` `string` _(required)_: ISO asset code, e.g. IDR, USD, USDC.
  - `formatted` `string` _(required)_: Machine decimal; ungrouped and dot-separated.
  - `display` `string` _(required)_: Localized display text. Never parse this value.
- `maxTimeoutSeconds` `integer` _(required)_
- `listed` `boolean` _(required)_: Whether it appears in the public x402 resource index.
- `accepts` `object[]` _(required)_
  - `chain` `string` _(required)_
  - `asset` `string` _(required)_
  - `contract` `string` _(required)_
  - `payTo` `string` _(required)_
  - `transferMethod` `string` _(required)_
  - `domain` `object` _(required)_

#### `404`: No resource with that id, or not this merchant's.

Body (`application/json`):

- `error` `object` _(required)_
  - `code` `string` _(required)_
  - `message` `string` _(required)_
  - `retryable` `boolean` _(required)_
  - `details` `object`

### Example request

```bash
curl https://api.mayarin.xyz/v1/x402/resources/string/unlist \
  --request POST
```

```ts
fetch('https://api.mayarin.xyz/v1/x402/resources/string/unlist', {
  method: 'POST'
})
```
