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

# Prefer header

Some API endpoints support custom `Prefer` headers to indicate preferences for specific server behaviors during request processing.
This allows the API to evolve, adding new features, while maintaining backwards compatibility where possible.

The `Prefer` header is optional for all API requests. Endpoints that don't support specific `Prefer` values ignore them without causing errors.

## `Prefer: resource=<resource_type>`

Currently, only the `Prefer: resource` header is supported by the API. This header allows a merchant to opt into a different resource
to return. Both the [void](/reference/transactions/void-transaction) and [capture](/reference/transactions/capture-transaction) endpoints support this header to opt into returning a specific resource type.

<Tabs>
  <Tab title="Void">
    For example, by setting the `Prefer: resource=transaction-void` on a void call, the response type is a `transaction-void` resource, rather than the standard
    `transaction` returned by this API.

    ```sh Request theme={"system"}
    POST /transactions/1a032928-abc0-4fb8-971e-fb917291e75f/void
    Prefer: resource=transaction-void
    ```

    ```json Response theme={"system"}
    {
      "type": "transaction-void",
      "status": "failed",
      "code": "service_error",
      "raw_response_code": "1001",
      "raw_response_description": "Internal error, please retry",
      "transaction": {
        "type": "transaction",
        "id": "1a032928-abc0-4fb8-971e-fb917291e75f",
        ...
      }
    }
    ```
  </Tab>

  <Tab title="Capture">
    For example, by setting the `Prefer: resource=transaction-capture` on a capture call, the response type is a `transaction-capture` resource, rather than the standard
    `transaction` returned by this API.

    ```sh Request theme={"system"}
    POST /transactions/1a032928-abc0-4fb8-971e-fb917291e75f/capture
    Prefer: resource=transaction-capture
    ```

    ```json Response theme={"system"}
    {
      "type": "transaction-capture",
      "status": "failed",
      "code": "service_error",
      "raw_response_code": "1001",
      "raw_response_description": "Internal error, please retry",
      "transaction": {
        "type": "transaction",
        "id": "1a032928-abc0-4fb8-971e-fb917291e75f",
        ...
      }
    }
    ```
  </Tab>
</Tabs>

<Note>
  Please note that HTTP header names are case-insensitive, as per HTTP standards, so `prefer`, `PREFER`, or `Prefer` can all be used. The value
  of a header is case-sensitive and needs to be lower-case to match both the `resource` key and the `<resource_type>` value.
</Note>
