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

# Update a Consumer

> This endpoint updates a Consumer.

## Request parameters

<Note>You cannot update the `stream_id` of an existing HTTP pull consumer.</Note>

<ParamField path="id" type="string" required>
  The ID of the consumer.
</ParamField>

<ParamField body="deliver_policy" type="string">
  Where in the stream the consumer starts.

  * `all` (default): the consumer will start from the beginning of the stream.
  * `new`: the consumer will start from the most recent message.
  * `last`: the consumer will start from the last message it received.
  * `1h`: the consumer will start from the most recent message from the last hour.

  <Warning>
    If you change the `deliver_policy` on the consumer, records may be replayed. For example, if you change the `deliver_policy` from `new` to `all`, the consumer will start from the beginning of the stream and replay all records.
  </Warning>
</ParamField>

<ResponseField name="ack_wait_ms" type="integer">
  How long to wait for a message to be acknowledged, in milliseconds. Defaults to `30000` (30 seconds).

  If a worker doesn't acknowledge a message within this time, the message will be redelivered (i.e. reappear for other workers to process).
</ResponseField>

<ResponseField name="max_deliver" type="integer">
  Maximum number of times a message can be redelivered to workers. For example, if a message causes your workers to crash, it will be redelivered up to `max_deliver` times before being discarded.

  Defaults to `-1`, which means there is no maximum.
</ResponseField>

<ResponseField name="max_ack_pending" type="integer">
  Maximum number of outstanding, acknowledged messages a consumer will allow at a time. Defaults to `1000`.

  After your workers have checked out `max_ack_pending` messages, the consumer will stop delivering messages until some are acknowledged.
</ResponseField>

<ParamField body="metadata" type="object">
  Metadata for the consumer. This is a JSON object that you can use to store any additional information you want to associate with the consumer.
</ParamField>

<RequestExample>
  ```shell Update a consumer theme={null}
  curl --request PATCH \
    --url https://api.sequin.io/v1/http-consumers/c906b4a4-0cda-4f46-bd80-255f570c195d \
    --header 'Authorization: Bearer YOUR_API_TOKEN' \
    --header 'Content-Type: application/json' \
    --data '{
      {
        "deliver_policy": "all",
        "max_ack_pending": 20000,
        "ack_wait_ms": 10000,
        "name": "Choam Corp - Primary Consumer",
        "metadata": { "custom_property": 42 }
      }
    }'
  ```
</RequestExample>

## Response fields

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "id": "c906b4a4-0cda-4f46-bd80-255f570c195d",
    "stream_id": "f0f70b52-5243-489c-879b-a1ae3f02abfd",
    "deliver_policy": "all",
    "ack_wait_ms": 30000,
    "max_deliver": -1,
    "max_ack_pending": 1000,
    "name": "Choam Corp - Primary Consumer",
    "metadata": { "custom_property": 42 },
    "created_at": "2023-12-15 01:29:29",
    "updated_at": "2023-12-15 01:29:29"
  }
  ```
</ResponseExample>

<ResponseField name="id" type="string">
  ID of the consumer.
</ResponseField>

<ResponseField name="stream_id" type="string">
  ID of the stream the consumer reads from.
</ResponseField>

<ResponseField name="deliver_policy" type="string">
  Where in the stream the consumer starts.

  * `all` (default): the consumer will start from the beginning of the stream.
  * `new`: the consumer will start from the most recent message.
  * `last`: the consumer will start from the last message it received.
  * `1h`: the consumer will start from the most recent message from the last hour.
</ResponseField>

<ResponseField name="ack_wait_ms" type="integer">
  How long to wait for a message to be acknowledged, in milliseconds. Defaults to `30000` (30 seconds).

  If a worker doesn't acknowledge a message within this time, the message will be redelivered (i.e. reappear for other workers to process).
</ResponseField>

<ResponseField name="max_deliver" type="integer">
  Maximum number of times a message can be redelivered to workers. For example, if a message causes your workers to crash, it will be redelivered up to `max_deliver` times before being discarded.

  Defaults to `-1`, which means there is no maximum.
</ResponseField>

<ResponseField name="max_ack_pending" type="integer">
  Maximum number of outstanding, acknowledged messages a consumer will allow at a time. Defaults to `1000`.

  After your workers have checked out `max_ack_pending` messages, the consumer will stop delivering messages until some are acknowledged.
</ResponseField>

<ResponseField name="metadata" type="object">
  Metadata for the sync. This is a JSON object that you can use to store any additional information you want to associate with the sync.
</ResponseField>

<ResponseField name="created_at" type="string">
  Timestamp of when the sync was created, in ISO 8601 format.
</ResponseField>

<ResponseField name="updated_at" type="string">
  Timestamp of when the sync was last updated, in ISO 8601 format.
</ResponseField>
