> ## 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.

# Atualizar ou Criar Página Web

> Aprenda a criar ou atualizar a página de uma loja usando o endpoint PUT /pages/{domain}.

## 📌 Endpoint

`PUT /pages/{domain}`

Cria ou atualiza a página da loja (upsert).

***

## 🔐 Autenticação

* **Rota privada**.
* Requer header `Authorization` com sua API key e plano ativo.

```json theme={null}
{
	"Authorization": "SUA_API_KEY_AQUI"
}
```

***

## 🧾 Parâmetros de rota

| Parâmetro | Tipo | Obrigatório | Descrição |
| - | - | - | - |
| `domain` | string | Sim | Domínio da loja |

***

## 🧍 Body (JSON)

| Campo | Tipo | Obrigatório | Regras |
| - | - | - | - |
| `html` | string | Sim | 60 até 1.000.000 caracteres (armazenado no Blob) |

***

## ✅ Exemplo de requisição

```bash theme={null}
curl -X PUT "https://api.cabrapi.com.br/v1/pages/minhaloja.com.br" \
	-H "Authorization: SUA_API_KEY_AQUI" \
	-H "Content-Type: application/json" \
	-d '{
		"html": "<html><body><h1>Minha loja personalizada na caBRAPI</h1></body></html>"
	}'
```

***

## Snippet padrão (cURL)

Use o exemplo cURL da seção Exemplo de requisição acima como snippet oficial.

***

## 📦 Resposta de sucesso (200)

```json theme={null}
{
	"code": "PAGE_UPSERTED"
}
```

***

## ⚠️ Possíveis erros

* `400 INVALID_DATA` → body/parâmetro inválido (`html` fora do intervalo de 60 a 1.000.000 caracteres ou `domain` inválido)
* `401 API_KEY_NOT_PROVIDED` → header `Authorization` não enviado
* `401 INVALID_API_KEY` → API Key inválida ou não encontrada
* `401 UNAUTHENTICATED` → sessão/usuário não autenticado
* `403 USER_DISABLED` → conta do usuário desativada ou excluída
* `403 NO_ACTIVE_SUBSCRIPTION` → conta sem plano ativo
* `404 STORE_NOT_FOUND` → loja não encontrada ou não pertence ao usuário
* `429 RATE_LIMIT_EXCEEDED` → limite de requisições por minuto do plano excedido
* `500 INTERNAL_SERVER_ERROR` → erro interno
* `502 PAGE_SAVE_FAILED` → falha ao salvar o arquivo HTML no armazenamento de blobs
* `503 SERVICE_UNAVAILABLE` → serviço temporariamente indisponível


## OpenAPI

````yaml PUT /pages/{domain}
openapi: 3.1.0
info:
  title: caBRAPI
  version: 1.0.0
servers:
  - url: https://api.cabrapi.com.br/v1
security: []
paths:
  /pages/{domain}:
    put:
      tags:
        - Store Page
      summary: Upsert web page
      operationId: upsertPage
      parameters:
        - $ref: '#/components/parameters/Domain'
      requestBody:
        required: true
        description: Page HTML (upsert by domain).
        content:
          application/json:
            schema:
              type: object
              required:
                - html
              properties:
                html:
                  type: string
                  minLength: 60
                  maxLength: 1000000
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: PAGE_UPSERTED
                    type: string
                required:
                  - code
                type: object
          description: Upsert web page.
        '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.
        '502':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Upstream gateway or storage error.
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Service unavailable.
      security:
        - ApiKey: []
components:
  parameters:
    Domain:
      in: path
      name: domain
      required: true
      schema:
        type: string
        minLength: 1
        maxLength: 255
  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.