# Offer routes: list, update, delete

URL: /code/api/offer/records-list · Id: `page:code/api/offer/records-list`

> The Offer Verbs list, update, delete as api.sb routes, with inputs, result, refusals and an example.

Reference for [Offer](/business/nouns/offer), one group of [Offer routes](/code/api/offer).

### Offer.list
Returns Offers, newest first, one page at a time. [Verb page](/business/nouns/offer/list?interface=api).

```text
GET /{namespace}/offers
```

Query: the inputs. Reads only: it emits no Event.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | `integer` | No | At most this many records, up to 100. The default is 20. |
| `after` | `string` | No | The cursor from the previous page. |
| `where` | `string` | No | A filter over the properties in the where grammar, such as `paidAt = null and total.amount > 500` (/code/api/guides/pagination-and-filtering#the-where-grammar). |
| `sort` | `string` | No | Properties to sort by, comma-separated; a leading minus sorts descending. |
| `total` | `boolean` | No | True adds the match count as `meta.total`, exact up to 10,000 matches and estimated above. |
| `facets` | `string` | No | Properties to count by value, comma-separated, returned as `meta.facets`. |
| `fields` | `string` | No | Properties to return on each record, comma-separated; `$id` and `$type` always return. |
| `include` | `string` | No | Related records to embed in place of their URLs, comma-separated. |
| `depth` | `integer` | No | How many levels of related records to embed. The default is 1. |
| `q` | `string` | No | Words to match across the text properties, ranked by relevance. |
| `match` | `string` | No | Ranks the search by `words`, or `meaning`; words is the default. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `offers` | list of [Offer](/business/nouns/offer) | Yes | One page of Offers. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
| `match` is not one of `words` or `meaning` | [`invalid-input`](/code/api/errors/invalid-input) | Send `match` as one of `words` or `meaning`. | None. |

**Example**

```bash
curl "https://api.sb/leaseline.app/offers?limit=20" \
  -H "Authorization: Bearer $SB_TOKEN"
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "$type": "Offer",
  "offers": [
    {
      "$id": "https://api.sb/leaseline.app/offers/offer_2hzYe1ERo0",
      "$type": "Offer",
      "price": {
        "amount": 29,
        "currency": "USD"
      }
    }
  ],
  "meta": {
    "limit": 20,
    "after": "offer_2hzYe1ERo0"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/offers?limit=20",
    "next": "https://api.sb/leaseline.app/offers?after=offer_2hzYe1ERo0"
  }
}
```

### Offer.update
Changes the given properties of an Offer. [Verb page](/business/nouns/offer/update?interface=api).

```text
PATCH /{namespace}/offers/{id}
```

Path: `id`. Body, as JSON: the other inputs. Emits `Offer.updated`.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Offer. |
| `price` | `money` | No | The amount and currency per period, or per unit its `meter` counts. Zero is a price. Never randomized. |
| `terms` | `text` | No | The conditions the Customer accepts, refund rights included. Never randomized. |
| `from` | `string` | No | Lineage: the slot it compiles from, as `Hypothesis#<slot>@v<version>`. |
| `activation` | `json` | No | The Event, count and window that mark a Customer activated, such as `Reminder.sent` 20 times within 7 days. |
| `credit` | `money` | No | The Credit Grant each purchase issues, for an Offer that sells prepaid credit, such as $50 of calls. |
| `name` | `string` | No | The name buyers see on the pricing table and the invoice, such as `Pro`. A declared Offer answers to its file name as its slug. |
| `atBound` | `string` | No | What a call past an Entitlement’s Limit gets: `stop`, `overage` or `upgrade` (refuse it, bill it through the Meter, or move to the next Offer). |
| `interval` | `string` | No | How often it bills: `once`, `day`, `week`, `month` or `year`. |
| `availableFrom` | `datetime` | No | When it can first be bought. Unset: from when it is published. |
| `availableUntil` | `datetime` | No | When it can last be bought. Existing Subscriptions continue past it. |
| `trial` | `json` | No | The free trial every new Customer starts with: `days`, and `card` true to take a card up front. Unset: no trial. |
| `seats` | `string` | No | How a per-seat Price counts: `manual` (the buyer sets the quantity) or `members` (people in the Customer’s Tenant, prorated as they change). |
| `uptime` | `json` | No | The monthly uptime it promises, and the share of that month’s charge credited back below each level. |
| `license` | `string` | No | What a buyer may do with the records it sells: use them `internal`ly, `display` them to its own users, or `redistribute` them. |
| `attribution` | `text` | No | The credit line a buyer shows wherever the records appear. |
| `privateTo` | [Party](/business/nouns/party) | No | The one Party who sees it and may accept it, making it a private Offer; no pricing page lists it. |
| `meter` | [Meter](/business/nouns/meter) | No | The Meter whose count it bills, for a usage-priced Offer: each unit the Meter counts bills at `price`. |
| `refundable` | `boolean` | No | True for a refundable deposit: refunded in full on request before `shipBy`, and to every buyer when `shipBy` passes unshipped. |
| `shipBy` | `date` | No | The date a deposit Offer promises to ship by; past it unshipped, every deposit refunds on its own. |
| `product` | [Product](/business/nouns/product) | No | The Product it sells. Omitted on create: the Startup’s only Product; with several, the call is refused with `invalid-input` until one is named. |
| `convertsTo` | `string` | No | What a deposit pays at ship: `firstInvoice` (the first period of a Subscription) or `firstOrder` (the first Order). |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `offer` | [Offer](/business/nouns/offer) | Yes | The Offer. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
| `id` is missing, or is not a string | [`invalid-input`](/code/api/errors/invalid-input) | Send `id` as a string, then call it again. | None. |
| `atBound` is not one of `stop`, `overage` or `upgrade` | [`invalid-input`](/code/api/errors/invalid-input) | Send `atBound` as one of `stop`, `overage` or `upgrade`. | None. |
| `interval` is not one of `once`, `day`, `week`, `month` or `year` | [`invalid-input`](/code/api/errors/invalid-input) | Send `interval` as one of `once`, `day`, `week`, `month` or `year`. | None. |
| `seats` is not one of `manual` or `members` | [`invalid-input`](/code/api/errors/invalid-input) | Send `seats` as one of `manual` or `members`. | None. |
| `license` is not one of `internal`, `display` or `redistribute` | [`invalid-input`](/code/api/errors/invalid-input) | Send `license` as one of `internal`, `display` or `redistribute`. | None. |
| `product`: omitted on create: the Startup’s only Product; with several, the call is refused with `invalid-input` until one is named | [`invalid-input`](/code/api/errors/invalid-input) | Send `product`, then call it again. | None. |
| `convertsTo` is not one of `firstInvoice` or `firstOrder` | [`invalid-input`](/code/api/errors/invalid-input) | Send `convertsTo` as one of `firstInvoice` or `firstOrder`. | None. |
| The `Idempotency-Key` was sent before with another operation or other input | [`idempotency-mismatch`](/code/api/errors/idempotency-mismatch) | Send a new key for new input; reuse a key only to retry the same request. | None. |

**Example**

```bash
curl -X PATCH https://api.sb/leaseline.app/offers/offer_2hzYe1ERo0 \
  -H "Authorization: Bearer $SB_TOKEN" \
  -H "Idempotency-Key: leaseline-offer-update-1" \
  -H "Content-Type: application/json" \
  -d '{"price":{"amount":29,"currency":"USD"}}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "offer": {
    "$id": "https://api.sb/leaseline.app/offers/offer_2hzYe1ERo0",
    "$type": "Offer",
    "price": {
      "amount": 29,
      "currency": "USD"
    }
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Offer.update",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

### Offer.delete
Deletes an Offer: a soft delete that keeps its history, undone by `Thing.restore`. [Verb page](/business/nouns/offer/delete?interface=api).

```text
DELETE /{namespace}/offers/{id}
```

Path: `id`. Emits `Offer.deleted`.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Offer. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `offer` | [Offer](/business/nouns/offer) | Yes | The Offer. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
| `id` is missing, or is not a string | [`invalid-input`](/code/api/errors/invalid-input) | Send `id` as a string, then call it again. | None. |
| The `Idempotency-Key` was sent before with another operation or other input | [`idempotency-mismatch`](/code/api/errors/idempotency-mismatch) | Send a new key for new input; reuse a key only to retry the same request. | None. |

**Example**

```bash
curl -X DELETE https://api.sb/leaseline.app/offers/offer_2hzYe1ERo0 \
  -H "Authorization: Bearer $SB_TOKEN" \
  -H "Idempotency-Key: leaseline-offer-delete-1"
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "offer": {
    "$id": "https://api.sb/leaseline.app/offers/offer_2hzYe1ERo0",
    "$type": "Offer",
    "price": {
      "amount": 29,
      "currency": "USD"
    }
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Offer.delete",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```