---
title: "Update an AI Gateway's attribution plugin"
method: PATCH
path: "/v1/ai-cost-management/ai-gateways/{gatewayId}/attribution-plugin"
tags: ["attribution-plugins"]
---

# Update an AI Gateway's attribution plugin

`PATCH /v1/ai-cost-management/ai-gateways/{gatewayId}/attribution-plugin`

## Request

- Base URL: `https://global.api.konghq.com`
- URL: `https://global.api.konghq.com/v1/ai-cost-management/ai-gateways/{gatewayId}/attribution-plugin`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer

Changes part of an installation's configuration with a JSON Merge Patch, installs the latest plugin version with the result, and returns the installation.

- An omitted field keeps its stored value, and an array, such as `headers`, replaces the stored one whole.
- `operator_tags` merges per key, and a key set to `null` is removed.
- `null` returns `headers`, `prefixes`, `operator_tags`, or `group_patterns` to its empty default. `integrations` can't be `null`.
- Like `PUT`, the request writes the plugin through the AI Gateway API as the caller, and it updates an outdated installation to the latest version.
- If the gateway has no installation, or the identifier isn't a valid ID, the request fails with `404`. The request never installs the plugin.
- The body is `application/merge-patch+json` or `application/json`. Any other media type fails with `415`.
- If the patch, or the configuration it produces, is invalid, the request fails with `400`.
- If another change to the gateway's plugin is running, the request fails with `409` and changes nothing. Repeat it once that change has finished.

## Path parameters

- `gatewayId` string, uuid, required

## Request body

- AICostAttributionPluginPatch: A JSON Merge Patch of an attribution plugin installation's configuration. An omitted field keeps its value, an array replaces the stored one, and `null` returns a field to its default. `operator_tags` merges per key.
  - `integrations` AICostAttributionPluginIntegration[]: The integrations whose headers the plugin reads. Any other tool's headers are ignored.
  - `headers` AICostAttributionPluginHeaderMapping[], nullable: Request headers mapped to tag keys. Each header name and each tag key appears once, and `headers` and `prefixes` hold at most 32 entries together.
    - `name` string, required: The request header, compared case-insensitively. A credential header, or the start of one such as `x-goog` for `x-goog-api-key`, is refused.
    - `tag_key` string, required: The tag key the header's value becomes.
  - `prefixes` AICostAttributionPluginPrefixMapping[], nullable: Header prefixes whose headers become tags. Each prefix appears once, and `headers` and `prefixes` hold at most 32 entries together.
    - `name` string, required: The prefix, compared case-insensitively. Every header named `<name>-<remainder>` becomes the tag `<remainder>`. A credential header, or the start of one, is refused.
  - `operator_tags` object, nullable: Tags the plugin adds to every request. The patch merges per key, and a key set to `null` is removed. A key has at most 128 characters: lowercase letters and digits in words joined by single hyphens.
  - `group_patterns` string[], nullable: PCRE regular expressions that choose which groups the plugin keeps from the caller's token. A group is kept when any pattern matches its name, case-insensitively and anywhere in the name unless the pattern anchors itself. An empty list keeps every group, and each pattern appears once.

## Response `200`

The installation after the update.

- AICostAttributionPlugin: The attribution plugin installed on one AI Gateway, with its configuration.
  - `gateway_id` string, uuid, required: The ID of the AI Gateway the plugin is installed on.
  - `version` string, required: The plugin version installed on the gateway.
  - `latest_version` string, required: The newest plugin version. When it differs from `version`, a `PUT` of the stored configuration installs it.
  - `integrations` AICostAttributionPluginIntegration[], required: The integrations whose headers the plugin reads.
  - `headers` AICostAttributionPluginHeaderMapping[], required: Request headers mapped to tag keys.
    - `name` string, required: The request header, compared case-insensitively. A credential header, or the start of one such as `x-goog` for `x-goog-api-key`, is refused.
    - `tag_key` string, required: The tag key the header's value becomes.
  - `prefixes` AICostAttributionPluginPrefixMapping[], required: Header prefixes whose headers become tags.
    - `name` string, required: The prefix, compared case-insensitively. Every header named `<name>-<remainder>` becomes the tag `<remainder>`. A credential header, or the start of one, is refused.
  - `operator_tags` object, required: Tags the plugin adds to every request.
  - `group_patterns` string[], required: PCRE regular expressions that choose which groups the plugin keeps from the caller's token.
  - `created_at` string, date-time, required: An ISO-8601 timestamp representation of entity creation date.
  - `updated_at` string, date-time, required: An ISO-8601 timestamp representation of entity update date.

## Other responses

- `400`: The patch, or the configuration it produces, is invalid, or the AI Gateway API refused it. `invalid_parameters` names each invalid field.
- `401`: The request has no valid access token. The token is missing, malformed, or expired, or it fails another check, and the response doesn't say which.
- `403`: The access token is valid, but its principal lacks the permission this operation requires. For an operation on one resource, the response doesn't reveal whether that resource exists.
- `404`: The AI Gateway has no attribution plugin installation.
- `409`: The gateway has a custom policy or policy of this name that this product didn't install, the plugin's policy is missing and a data plane runs with streaming off, or another change to its plugin is running.

## Changes

- **2026-11-19** `3b071797f6e4`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/kong/apis/konnect-api-go-sdk/changes/v1/ai-cost-management/ai-gateways/:gatewayId/attribution-plugin/patch.md)

---

[API](https://skmtc.dev/kong/apis/konnect-api-go-sdk.md) - [All operations](https://skmtc.dev/kong/apis/konnect-api-go-sdk/llms.txt) - [OpenAPI document](https://skmtc.dev/kong/apis/konnect-api-go-sdk/revisions/3b071797f6e4?raw)
