> ## Documentation Index
> Fetch the complete documentation index at: https://docs.isnap.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Update the metadata of a pre-order

> Merges metadata into a pre-order of your account.

* **Credential:** an API key of the account that owns the pre-order.
* **Line-scoped keys:** the list of lines of a [line-scoped key](/authentication#line-scoped-keys) is not applied.
* **`Idempotency-Key`:** not honored. See [Operations that honor the key](/idempotency#operations-that-honor-the-key).
* **Events:** none. The events sent after the call carry the new `metadata`. The call works in every status.
* **Body:** required. It has one field, `metadata`, and is sent with `Content-Type: application/json`. The merge rules are in [Metadata](/guides/pre-orders#metadata).

## Errors

| Status | `error.code` | When |
| - | - | - |
| 400 | `validation_failed` | `id` is not a UUID, the body is missing or has an unknown field, or its `metadata` is over 20 keys or 8,192 bytes. |
| 400 | `metadata_too_large` | The merged `metadata` is over 20 keys or 8,192 bytes. A request that only deletes keys is never refused for the size of the result. |
| 404 | `not_found` | The id is unknown, or the pre-order belongs to another account. |

The errors that every operation shares are in [Errors](/errors-and-rate-limits#errors).


## OpenAPI

````yaml PATCH /v1/pre-orders/{id}
openapi: 3.0.0
info:
  title: iSnap API
  version: 2.45.0
  description: >-
    The iSnap API sends and receives iMessage, RCS and SMS on real phone lines,
    manages those lines, and reports events through webhooks. Every message is
    sent to a real recipient, with an `isnap_live_` key and with an
    `isnap_test_` key alike. Retry a `429` after `Retry-After` seconds. Retry a
    `500` or a `503` up to 2 times, with exponential backoff. Do not retry any
    other `4xx`: fix the request. Retry a write only on an operation that honors
    `Idempotency-Key`, with the key of the first attempt. Responses carry
    personal data: handles, names and message text.
servers:
  - url: https://api.isnap.ai
security:
  - bearerAuth: []
paths:
  /v1/pre-orders/{id}:
    patch:
      summary: Update the metadata of a pre-order
      description: >-
        Merges `metadata` into the metadata of a pre-order of the account: a key
        you send overwrites, a key sent as `null` is deleted, every other key is
        kept. Accepts an API key. A line-scoped key is not limited to its list
        on this operation. The patch holds at most 20 keys and 8,192 bytes once
        serialized as JSON, otherwise the call returns `400 validation_failed`;
        so does the result of the merge, otherwise the call returns `400
        metadata_too_large`. A patch that only deletes keys is never refused for
        the size of the result. An empty `metadata` object changes nothing.
        Allowed in every status, `fulfilled` and `cancelled` included. Every
        `pre_order.*` event recorded after the call carries the new metadata as
        `data.metadata`; an event already recorded keeps the metadata it was
        recorded with, on its retries and replays too. The metadata is not
        copied onto the line that the pre-order produces. The JSON body is
        required. A pre-order of another account, or an unknown id, returns `404
        not_found`. Updating the metadata sends no event.
      parameters:
        - schema:
            type: string
            format: uuid
            description: >-
              Id of the pre-order: the UUID returned in `id` by `POST
              /v1/pre-orders`.
            example: 7f3b9c1e-2a4d-4f6b-8e0a-5c1d2e3f4a5b
          required: true
          description: >-
            Id of the pre-order: the UUID returned in `id` by `POST
            /v1/pre-orders`.
          name: id
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PatchPreOrder'
      responses:
        '200':
          description: The pre-order, with its metadata after the merge.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                    description: Always `true` on a success response.
                  data:
                    $ref: '#/components/schemas/PreOrder'
                  trace_id:
                    type: string
                    description: >-
                      Trace id of the request that produced this response: 32
                      lowercase hexadecimal characters. Quote it when you report
                      a problem to iSnap.
                  request_id:
                    type: string
                    description: >-
                      Id of the request that produced this response: `req_`
                      followed by 25 letters or digits.
                required:
                  - success
                  - data
                  - trace_id
                  - request_id
        '400':
          description: >-
            Invalid request. `error.code` is `validation_failed` when a
            parameter, a header or the body does not match its schema:
            `error.issues` then lists each problem. It is `metadata_too_large`
            when the metadata would hold more than 20 keys or 8,192 bytes after
            the merge.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '401':
          description: No valid credential. `error.code` is `unauthorized`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '404':
          description: >-
            Not found. `error.code` is `not_found`: the account has no pre-order
            with this id.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '429':
          description: >-
            Too many requests. `error.code` is `rate_limit_exceeded` when more
            than 100 requests came from the same network address in 60 seconds,
            whatever their API key or account: wait `error.retry_after` seconds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '500':
          description: >-
            Unexpected failure. `error.code` is `internal_error`. An operation
            that takes a JSON body also returns it when the body, sent as
            `application/json`, is not valid JSON. Quote `trace_id` when you
            report it to iSnap.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
      security:
        - bearerAuth: []
components:
  schemas:
    PatchPreOrder:
      type: object
      properties:
        metadata:
          type: object
          additionalProperties:
            nullable: true
          description: >-
            Keys to merge into the metadata of the pre-order. A key with a value
            is set, and a key with `null` is deleted. At most 20 keys and 8,192
            bytes once serialized as JSON.
          example:
            crm_account_id: acc_123
            campaign: null
      required:
        - metadata
      additionalProperties: false
      description: Metadata to merge into the metadata of a pre-order.
    PreOrder:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: 'Id of the pre-order: a UUID.'
        preferred_area_codes:
          type: array
          items:
            type: string
          description: The area codes you listed, in order of preference.
        inbound_only:
          type: boolean
          description: '`true` for an inbound-only line, `false` for a two-way line.'
        billing_anchor_at:
          type: string
          nullable: true
          description: >-
            The billing anchor you set when creating the pre-order, carried onto
            the line when the line is created. `null` when you set none.
        status:
          $ref: '#/components/schemas/PreOrderStatus'
        stripe_client_secret:
          type: string
          nullable: true
          description: >-
            Client secret for the payment form of Stripe, to collect the first
            month. Set only in the response of `POST
            /v1/pre-orders/{id}/confirm`, when that response carries the
            pre-order in status `awaiting_payment`: the first time and every
            time confirm is repeated. `null` in every other response.
        estimated_fulfillment:
          type: string
          nullable: true
          description: >-
            Estimated time of the hand-over of the line: the time the build
            starts plus 72 hours. Set once, when the build starts, and never
            revised. `null` while the pre-order is `draft` or
            `awaiting_payment`, and on a pre-order canceled before its build
            started.
        device_status:
          $ref: '#/components/schemas/DeviceFulfillmentStatus'
        created_at:
          type: string
          description: Timestamp of creation, ISO 8601 in UTC.
        updated_at:
          type: string
          description: Timestamp of the last change of the pre-order, ISO 8601 in UTC.
        metadata:
          type: object
          nullable: true
          additionalProperties:
            nullable: true
          description: >-
            Your metadata on the pre-order, set at creation or with `PATCH
            /v1/pre-orders/{id}`, and sent as `data.metadata` on every
            `pre_order.*` event. `null` when the pre-order has none. It is not
            copied onto the line that the pre-order produces.
          example:
            crm_account_id: acc_123
      required:
        - id
        - preferred_area_codes
        - inbound_only
        - billing_anchor_at
        - status
        - stripe_client_secret
        - estimated_fulfillment
        - created_at
        - updated_at
        - metadata
      description: 'A pre-order: an order for one rented iMessage line.'
    ErrorEnvelope:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - false
          description: Always `false` on an error response.
        data:
          nullable: true
          description: Always `null` on an error response.
        error:
          type: object
          properties:
            status:
              type: integer
              description: The HTTP status of the response.
            code:
              type: string
              description: >-
                Stable machine-readable code that names the refusal. Branch on
                this value.
            message:
              type: string
              description: >-
                Text for a person. It can change between versions: do not branch
                on it.
            retry_after:
              type: integer
              nullable: true
              description: >-
                Seconds to wait before the next attempt. Set on the `429`
                responses that know a delay, where the `Retry-After` header
                carries the same value. When it is above 60 seconds, do not wait
                in a request: schedule the call, or report the time. `null` on
                every other error.
            retry_at:
              type: string
              nullable: true
              description: >-
                ISO 8601 timestamp at which the refusal ends. Set only on `429
                rebind_cap_reached`. `null` on every other error.
            issues:
              type: array
              nullable: true
              items:
                type: object
                properties:
                  path:
                    type: array
                    items:
                      anyOf:
                        - type: string
                        - type: number
                    description: >-
                      Where the problem is: the field names and array indexes
                      that lead to it.
                  message:
                    type: string
                    description: Text for a person.
                  code:
                    type: string
                    description: >-
                      Kind of problem. On `validation_failed`, for example
                      `invalid_type`, `invalid_value`, `invalid_format`,
                      `invalid_union`, `invalid_key`, `invalid_element`,
                      `too_small`, `too_big`, `not_multiple_of`,
                      `unrecognized_keys` or `custom`. The list is open: read
                      `path` and `message`.
                  min:
                    type: integer
                    description: >-
                      Smallest accepted value. Present only on
                      `limit_out_of_bounds`, `mac_quantity_not_a_pack`,
                      `byop_reduction_strands_mac_sessions` and
                      `byop_reduction_strands_byod_lines`.
                  max:
                    type: integer
                    description: >-
                      Largest accepted value. Present only on
                      `limit_out_of_bounds` and
                      `mac_sessions_exceed_byop_lines`, and on the `too_big`
                      issue of an `Idempotency-Key` header longer than 255
                      characters.
                required:
                  - path
                  - message
                  - code
              description: >-
                Problems found in the request, one entry each. Set on most `400
                validation_failed` responses and on the refusals that name a
                field: a refused `handle` of `POST /v1/lookup` has `issues:
                null`. `null` on every other error.
          required:
            - status
            - code
            - message
            - retry_after
            - retry_at
            - issues
          description: >-
            What went wrong. The six fields are always present; `retry_after`,
            `retry_at` and `issues` are `null` when they do not apply.
        trace_id:
          type: string
          description: >-
            Trace id of the request that produced this response: 32 lowercase
            hexadecimal characters. Quote it when you report a problem to iSnap.
        request_id:
          type: string
          description: >-
            Id of the request that produced this response: `req_` followed by 25
            letters or digits.
      required:
        - success
        - data
        - error
        - trace_id
        - request_id
      description: The body of an error response.
    PreOrderStatus:
      type: string
      enum:
        - draft
        - awaiting_payment
        - provisioning
        - fulfilled
        - cancelled
      description: >-
        `draft`: created, with no effect. `awaiting_payment`: confirmed by a
        direct account, and the first month is due; nothing is built until it is
        paid. `provisioning`: the build has started, and the line is being
        prepared. `fulfilled`: the line is handed over. `cancelled`: the
        pre-order ended with no line. You canceled it, its first month was not
        paid within 23 hours of the confirmation, or its subscription was
        canceled before the first payment. A pre-order whose build has started
        never becomes `cancelled`.
    DeviceFulfillmentStatus:
      type: string
      nullable: true
      enum:
        - awaiting_hardware
        - received
        - setup_in_progress
        - ready
        - deployed
        - null
      description: >-
        Progress of the line. `awaiting_hardware`: the line is not ready; also
        the value of a pre-order that has no line: a draft, a pre-order in
        `awaiting_payment`, a canceled pre-order. `ready`: the line is prepared.
        `deployed`: the line is handed over. `received` and `setup_in_progress`
        are declared and never returned. Always present on a pre-order, and
        never `null`.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        An API key created in the iSnap dashboard, or a trial key, sent as
        `Authorization: Bearer <key>`. An API key starts with `isnap_live_` or
        `isnap_test_`; both act on the same account, lines and billing. A trial
        key acts on its trial only.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.