# OTC and RFQ HTTP API



Use `https://api.spectra.finance/v1/{network}/otc` as the base URL. The network can be the chain ID or slug for Base, Flare or Katana. Send POST bodies as JSON. For signing, pricing and settlement, see [OTC orders and RFQ](/docs/integration-reference/otc-rfq).

## Endpoints [#endpoints]

| Method and path     | Request                                                                                                                        | Successful JSON response                                                                                                                                          |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GET /config`       | No body                                                                                                                        | `{ success: true, data: { limitOrderProtocol, rateAmountGetter, authorizedTakersGuard, orderSigner } }`. Each field is a contract address on the requested chain. |
| `GET /orders`       | Optional filters below                                                                                                         | `{ success: true, data: [orderEnvelope, …] }`                                                                                                                     |
| `POST /create`      | `{ envelope: orderEnvelope }`                                                                                                  | `{ success: true, orderHash }`                                                                                                                                    |
| `POST /rfq/create`  | `{ envelope: quoteRequestEnvelope }`                                                                                           | `{ success: true, requestHash }`                                                                                                                                  |
| `GET /rfq/requests` | Exactly one of `requester` or `vault` (address). For requester history, add `includeClosed=true`.                              | `{ success: true, data: { requests, responseOrders } }`                                                                                                           |
| `POST /rfq/respond` | `{ requestHash, vault, orderHash }` for a published response order made by that vault                                          | `{ success: true }`                                                                                                                                               |
| `POST /rfq/decline` | `{ requestHash, vault, signer, signature }`. The signer must be a curator role member, configurator role member or Safe owner. | `{ success: true }`                                                                                                                                               |
| `POST /rfq/cancel`  | `{ requestHash, signature }` signed by the requester                                                                           | `{ success: true }`                                                                                                                                               |

### Order filters [#order-filters]

Filter by `market` (PT address), `makerAddress` or `derivativeKind` (`0` for PT, `1` for YT). By default the book returns active orders on the current deployment. Pass `includeInactive=true` to include delisted, expired, closed, temporarily unfillable and superseded-deployment orders. `limit` defaults to 100 and is capped at 1,000. `offset` defaults to zero and accepts integers through 9,000.

## Order envelope [#order-envelope]

| Fields                                 | JSON type              | Meaning                                                                                                                                                                                                                                          |
| -------------------------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `schema`, `schemaVersion`, `orderType` | string, number, string | Fixed values `"spectra-otc"`, `1` and `"RATE"`.                                                                                                                                                                                                  |
| `chainId`, `settlementAddress`         | number, address        | Signing chain and settlement contract.                                                                                                                                                                                                           |
| `orderHash`                            | 32-byte hex string     | EIP-712 digest of the order in its settlement domain.                                                                                                                                                                                            |
| `order`                                | object                 | The signed fields below.                                                                                                                                                                                                                         |
| `extension`, `signature`               | hex strings            | Rate-order bytes bound by the salt and the maker’s signature. For publication, send a 65-byte ECDSA signature for an EOA. A contract maker may use ERC-1271 signature bytes up to 1,024 bytes, including `0x` when its onchain check accepts it. |
| `authorizedTakers`                     | optional address array | For a private order, exactly the takers in its signed extension in the same order.                                                                                                                                                               |
| `createdAt`, `createdAtBlock`          | decimal strings        | Creation time in Unix seconds and creation block number.                                                                                                                                                                                         |
| `metadata`                             | optional object        | Display information. Read signed terms from the order and extension.                                                                                                                                                                             |

The signed `order` fields follow the [EIP-712 field order and types](/docs/integration-reference/evm-limit-orders/encoding#signature-domain).

| Field                          | JSON type       | Meaning                                                                                                                    |
| ------------------------------ | --------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `salt`                         | decimal string  | Unsigned 256-bit salt binding the extension.                                                                               |
| `maker`, `receiver`            | addresses       | Asset owner and receiver override. OTC requires the zero address for the receiver, so payment goes to the maker.           |
| `makerAsset`, `takerAsset`     | addresses       | Tokens delivered by the maker and taker, respectively.                                                                     |
| `makingAmount`, `takingAmount` | decimal strings | Positive quantities in the respective assets’ base units. The first is fixed and the second is the creation-time baseline. |
| `makerTraits`                  | decimal string  | Unsigned 256-bit value encoding fill policy, expiry, nonce and extension flags.                                            |

A listed order’s `metadata` can include `invalidated`, `allowsPartialFills`, `remainingMakingAmount` (decimal base units) and `outcome` (`FILLED`, `CANCELLED` or null). Once cancelled, the remaining amount records what the cancellation withdrew. Temporary `unfillableReason` values are `INSUFFICIENT_BALANCE`, `INSUFFICIENT_ALLOWANCE`, `SIGNATURE_INVALID` and `PRICING_UNAVAILABLE`. Refresh the price and fillability onchain before submitting a fill.

## Quote request envelope [#quote-request-envelope]

Send `schema: "spectra-otc-rfq"`, `schemaVersion: 1`, numeric `chainId`, the 32-byte `requestHash`, a `request` object and hex `signature`. Use a 65-byte signature for an EOA or an ERC-1271 signature of up to 1,024 bytes for a contract requester. Sign these types in the RFQ domain. The hash for a decline or cancellation identifies the original quote request.

```text
QuoteRequest(address requester,uint8 derivativeKind,uint8 quoteKind,string side,address underlying,address ibt,address pt,uint256 maturity,uint256 amount,address[] recipients,uint256 expiry,uint256 salt)
DeclineQuoteRequest(bytes32 requestHash,address vault)
CancelQuoteRequest(bytes32 requestHash)
```

| Request fields                | JSON type       | Meaning                                                                                                     |
| ----------------------------- | --------------- | ----------------------------------------------------------------------------------------------------------- |
| `requester`                   | address         | Account asking for quotes.                                                                                  |
| `derivativeKind`, `quoteKind` | numbers         | Derivative is PT (`0`) or YT (`1`). Quote token is underlying (`0`) or IBT (`1`).                           |
| `side`                        | string          | `BUY` or `SELL` from the requester’s perspective.                                                           |
| `underlying`, `ibt`, `pt`     | addresses       | Assets identifying the market. Use a zero PT to request a new market.                                       |
| `maturity`, `expiry`          | decimal strings | Market maturity and request expiry in Unix seconds. Expiry must be in the future and at or before maturity. |
| `amount`                      | decimal string  | Positive PT or YT quantity in derivative base units.                                                        |
| `recipients`                  | address array   | One to 16 distinct recipient vault Safes.                                                                   |
| `salt`                        | decimal string  | Unsigned 256-bit value distinguishing requests with otherwise identical terms.                              |

## Request history and responses [#request-history-and-responses]

The requester view returns each request as `{ chainId, requestHash, request, cancelled, createdAt, recipients }`. The `createdAt` field uses Unix seconds as a decimal string. Each recipient is `{ vault, status, orderHash }`, with status `PENDING`, `DECLINED` or `RESPONDED` and a nullable order hash. Match a responded row to its envelope in `responseOrders` by hash. Verify a signature against the original signed recipient ordering.

The vault view includes only that vault’s recipient row on each open request and returns an empty `responseOrders` array. Read the vault’s signed orders through `GET /orders`.

## Errors [#errors]

An error response has `success: false` and an `error` message. HTTP 400 indicates an unsupported network, malformed request or invalid filter. HTTP 422 indicates a write that failed a signature, market, authorization or lifecycle check. HTTP 503 indicates the service, required configuration or authority check is unavailable. Publishing an identical accepted order again returns its hash and preserves its current state.
