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

# Update Store Webhook

> Updates the subscribed events list for an existing webhook registered on the store.

## 🔄 Update Store Webhook

This endpoint updates the subscribed `events` for a webhook already registered on the store. Both `PUT` and `PATCH` are supported with the exact same request body.

### 🔐 Authentication

This route requires API Key authentication in the request header:

```http theme={null}
Authorization: YOUR_API_KEY_HERE
```

### 📥 Path Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `storeId` | `string (UUID)` | Yes | Store ID |

### 📦 Request Body

| Field | Type | Required | Description |
| - | - | - | - |
| `url` | `string (URI)` | Yes | Registered webhook URL (`http://` or `https://`, `9` to `200` characters). |
| `events` | `string[]` | Yes | List of subscribed events (minimum 1 item; must be valid supported webhook events). |

### 📋 Request Example

```bash theme={null}
curl --location --request PUT "https://api.cabrapi.com.br/v1/stores/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/webhooks" \
--header "Authorization: YOUR_API_KEY_HERE" \
--header "Content-Type: application/json" \
--data '{
  "url": "https://meusistema.com/callback",
  "events": [
    "payment.status.changed",
    "payment.updated"
  ]
}'
```

> You can also send a `PATCH` request to the same path (`/v1/stores/{storeId}/webhooks`) with the same payload.

### 📊 Response Example (200)

```json theme={null}
{
  "code": "WEBHOOK_UPDATED",
  "webhook": "https://meusistema.com/callback",
  "events": [
    "payment.status.changed",
    "payment.updated"
  ]
}
```

### ❌ Possible Errors

| Status | Code | When it happens |
| - | - | - |
| `400` | `STORE_ID_REQUIRED` | Dead code: the route requires `storeId`; never fires in practice. |
| `400` | `INVALID_URL` | `url` is missing or not a valid HTTP/HTTPS URL (`9` to `200` characters). |
| `400` | `INVALID_DATA` | `events` is omitted, sent as an empty array (`[]`), or contains one or more invalid webhook event names. |
| `401` | `API_KEY_NOT_PROVIDED` | Missing `Authorization` header. |
| `401` | `INVALID_API_KEY` | Invalid or unknown API key. |
| `403` | `USER_DISABLED` | User account disabled or deleted. |
| `403` | `NO_ACTIVE_SUBSCRIPTION` | Account has no active plan. |
| `404` | `STORE_NOT_FOUND` | Store does not exist. |
| `404` | `WEBHOOK_NOT_FOUND` | The provided `url` is not registered on this store. |
| `429` | `RATE_LIMIT_EXCEEDED` | Plan per-minute rate limit exceeded. |
| `500` | `WEBHOOK_ERROR` | Internal error while saving webhook events. |
| `503` | `SERVICE_UNAVAILABLE` | Service temporarily unavailable. |


## OpenAPI

````yaml PUT /stores/{storeId}/webhooks
openapi: 3.1.0
info:
  title: caBRAPI
  version: 1.0.0
servers:
  - url: https://api.cabrapi.com.br/v1
security: []
paths:
  /stores/{storeId}/webhooks:
    put:
      tags:
        - Webhooks
      summary: Update webhook events
      operationId: updateWebhook
      parameters:
        - $ref: '#/components/parameters/StoreId'
      requestBody:
        content:
          application/json:
            schema:
              properties:
                events:
                  items:
                    enum:
                      - store.created
                      - store.updated
                      - store.deleted
                      - store.reordered
                      - product.created
                      - product.updated
                      - product.deleted
                      - product.reordered
                      - category.created
                      - category.updated
                      - category.deleted
                      - category.reordered
                      - coupon.created
                      - coupon.updated
                      - coupon.deleted
                      - coupon.reordered
                      - page.upserted
                      - page.deleted
                      - affiliate.created
                      - affiliate.updated
                      - affiliate.deleted
                      - payment.created
                      - payment.updated
                      - payment.deleted
                      - payment.status.changed
                    type: string
                  minItems: 1
                  type: array
                url:
                  format: uri
                  maxLength: 200
                  minLength: 9
                  type: string
              required:
                - url
                - events
              type: object
        description: Webhook URL and updated event subscriptions.
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: WEBHOOK_UPDATED
                    type: string
                  events:
                    items:
                      enum:
                        - store.created
                        - store.updated
                        - store.deleted
                        - store.reordered
                        - product.created
                        - product.updated
                        - product.deleted
                        - product.reordered
                        - category.created
                        - category.updated
                        - category.deleted
                        - category.reordered
                        - coupon.created
                        - coupon.updated
                        - coupon.deleted
                        - coupon.reordered
                        - page.upserted
                        - page.deleted
                        - affiliate.created
                        - affiliate.updated
                        - affiliate.deleted
                        - payment.created
                        - payment.updated
                        - payment.deleted
                        - payment.status.changed
                      type: string
                    type: array
                  webhook:
                    format: uri
                    type: string
                required:
                  - code
                  - webhook
                  - events
                type: object
          description: Webhook updated.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Invalid request.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Missing or invalid API key.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Forbidden (inactive plan or insufficient permissions).
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Resource not found.
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Rate limit exceeded.
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Internal server error.
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Service unavailable.
      security:
        - ApiKey: []
components:
  parameters:
    StoreId:
      in: path
      name: storeId
      required: true
      schema:
        type: string
        minLength: 1
        maxLength: 50
  schemas:
    Error:
      properties:
        code:
          example: STORE_NOT_FOUND
          type: string
      required:
        - code
      type: object
  securitySchemes:
    ApiKey:
      in: header
      name: Authorization
      type: apiKey
      x-default: YOUR_API_KEY_HERE

````

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