Pagination

List endpoints return results in pages. Use limit and cursor to walk through them.

List endpoints (GET /v1/payments, /v1/refunds, /v1/payment-links, /v1/deposits) use cursor pagination and return newest items first. GET /v1/webhook-endpoints returns all your endpoints for the key's mode in one response, in the same list shape with has_more: false.

Request

ParameterDescription
limitItems per page, from 1 to 100. Default 20. A value outside that range fails with 422 validation_error.
cursorThe next_cursor from the previous response. Omit it for the first page. An invalid cursor fails with 422 validation_error.

Filters (such as status or created_gte on payments) stay the same on every page.

Response

{
  "data": [
    { "id": "pay_01JBX4T9W2", "object": "payment", "amount": 12500 },
    { "id": "pay_01JBX3Q8ZA", "object": "payment", "amount": 4000 }
  ],
  "has_more": true,
  "next_cursor": "eyJpZCI6InBheV8wMUpCWDNROFpBIn0"
}
FieldDescription
dataThe items on this page.
has_moretrue if there are more items after this page.
next_cursorOpaque string to pass as cursor for the next page, or null on the last page. Don't decode or build it yourself.

Fetch every page

async function* listAllPayments(params = {}) {
  let cursor;
  do {
    const query = new URLSearchParams({ limit: '100', ...params, ...(cursor ? { cursor } : {}) });
    const res = await fetch(`https://api.teyra.co/v1/payments?${query}`, {
      headers: { Authorization: `Bearer ${process.env.TEYRA_SECRET_KEY}` },
    });
    const page = await res.json();
    yield* page.data;
    cursor = page.has_more ? page.next_cursor : undefined;
  } while (cursor);
}

for await (const payment of listAllPayments({ status: 'succeeded' })) {
  console.log(payment.id, payment.amount);
}