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

> Aprenda a atualizar uma loja existente usando o endpoint PUT /stores/{storeId}.

## ✏️ Atualizar Loja

Este endpoint permite **atualizar dados de uma loja existente** da sua conta.

Ele é ideal para:

* Alterar nome, descrição e imagem da loja
* Trocar template e domínio
* Atualizar metadados para integrações internas

## 🔐 Autenticação

Esta rota **exige autenticação** via **API Key**, enviada no header da requisição:

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

## 📥 Parâmetros de Rota

| Parâmetro | Tipo | Obrigatório | Descrição |
| - | - | - | - |
| `storeId` | `string` | Sim | ID da loja que será atualizada (sem validação estrita de formato UUID; ID inexistente retorna `404 STORE_NOT_FOUND`). |

## 📥 Body da Requisição

> Pelo menos **1 campo** deve ser enviado no body.

| Campo | Tipo | Obrigatório | Descrição |
| - | - | - | - |
| `template` | `string` | Não | Valores aceitos: `PERSONALIZADO` ou `N/A`. |
| `position` | `number` | Não | Inteiro maior ou igual a 1 para reordenar manualmente. |
| `name` | `string` | Não | Nome da loja (mín. 4, máx. 32). |
| `description` | `string` | Não | Descrição da loja (mín. 12, máx. 256). |
| `image` | `string` | Não | URL da imagem da loja (mín. 12, máx. 512). |
| `metadata` | `object` | Não | Metadados customizados da loja. |
| `domain` | `object` | Condicional | Obrigatório quando `template = PERSONALIZADO`. |

### Estrutura de `domain`

| Campo | Tipo | Obrigatório | Descrição |
| - | - | - | - |
| `type` | `string` | Sim | Valores aceitos: `CUSTOM` ou `DEFAULT`. |
| `value` | `string` | Sim | Domínio ou subdomínio (mín. 8, máx. 75). |

## 📋 Exemplo de Requisição

```bash theme={null}
curl --location --request PUT "https://api.cabrapi.com.br/v1/stores/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
--header "Authorization: SUA_API_KEY_AQUI" \
--header "Content-Type: application/json" \
--data '{
	"name": "Minha Loja Atualizada",
	"template": "PERSONALIZADO",
	"domain": {
		"type": "DEFAULT",
		"value": "minha-loja-v2"
	}
}'
```

## 📊 Exemplo de Resposta (200)

```json theme={null}
{
	"code": "STORE_UPDATED",
	"store": {
		"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
		"name": "Minha Loja Atualizada",
		"position": 2,
		"description": "Loja oficial da minha marca",
		"image": "https://example.com/store.png",
		"domain": "minha-loja-v2-web.cabrapi.com.br",
		"template": "PERSONALIZADO",
		"metadata": null,
		"createdAt": "2026-02-28T12:00:00.000Z",
		"updatedAt": "2026-02-28T12:10:00.000Z"
	}
}
```

## ❌ Possíveis Erros

| Status | Code | Quando acontece |
| - | - | - |
| `400` | `INVALID_DATA` | Body JSON inválido ou nenhum campo enviado. |
| `400` | `INVALID_DATA_POSITION` | `position` menor que `1`. |
| `400` | `INVALID_DATA_NAME_MIN` | `name` possui menos de 4 caracteres. |
| `400` | `INVALID_DATA_NAME_MAX` | `name` possui mais de 32 caracteres. |
| `400` | `INVALID_DATA_DESCRIPTION_MIN` | `description` possui menos de 12 caracteres. |
| `400` | `INVALID_DATA_DESCRIPTION_MAX` | `description` possui mais de 256 caracteres. |
| `400` | `INVALID_DATA_IMAGE` | `image` fora do intervalo permitido (12 a 512 caracteres). |
| `400` | `INVALID_DATA_TEMPLATE` | `template` diferente de `PERSONALIZADO` e `N/A`. |
| `400` | `INVALID_DATA_DOMAIN` | `domain.type` diferente de `CUSTOM`/`DEFAULT` ou `domain.value` inválido (8 a 75 caracteres). |
| `400` | `DOMAIN_REQUIRED` | `template` é `PERSONALIZADO` e `domain` não foi enviado. |
| `400` | `DOMAIN_ALREADY_EXISTS` | Domínio já está sendo usado por outra loja. |
| `400` | `NAME_ALREADY_EXISTS` | Já existe loja com esse nome para o mesmo usuário. |
| `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 no contexto da requisição. |
| `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 existe, foi removida ou não pertence à sua conta. |
| `429` | `RATE_LIMIT_EXCEEDED` | Limite de requisições por minuto do plano excedido. |
| `500` | `INTERNAL_SERVER_ERROR` | Falha interna ao processar a requisição. |
| `503` | `SERVICE_UNAVAILABLE` | Serviço temporariamente indisponível. |

## 🔗 Links Úteis

* [Documentação de Autenticação](https://docs.cabrapi.com.br/pages/pt-BR/api-reference/authorization.md)
* [Buscar Lojas](https://docs.cabrapi.com.br/pages/pt-BR/api-reference/store/get.md)
* [Obter Loja por ID](https://docs.cabrapi.com.br/pages/pt-BR/api-reference/store/get-by-id.md)
* [Criar Loja](https://docs.cabrapi.com.br/pages/pt-BR/api-reference/store/post.md)
* [Excluir Loja](https://docs.cabrapi.com.br/pages/pt-BR/api-reference/store/delete.md)

Update: 28/02/2026 as 00:00


## OpenAPI

````yaml PUT /stores/{storeId}
openapi: 3.1.0
info:
  title: caBRAPI
  version: 1.0.0
servers:
  - url: https://api.cabrapi.com.br/v1
security: []
paths:
  /stores/{storeId}:
    parameters:
      - in: path
        name: storeId
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 50
    put:
      tags:
        - Stores
      summary: Update store
      operationId: updateStore
      parameters:
        - $ref: '#/components/parameters/StoreId'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StoreUpdate'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: STORE_UPDATED
                    type: string
                  store:
                    $ref: '#/components/schemas/Store'
                required:
                  - code
                  - store
                type: object
          description: Store updated.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: >-
            INVALID_DATA, INVALID_DATA_POSITION, INVALID_DATA_NAME_MIN,
            INVALID_DATA_NAME_MAX, INVALID_DATA_DESCRIPTION_MIN,
            INVALID_DATA_DESCRIPTION_MAX, INVALID_DATA_IMAGE,
            INVALID_DATA_TEMPLATE, INVALID_DATA_DOMAIN, DOMAIN_REQUIRED,
            DOMAIN_ALREADY_EXISTS, NAME_ALREADY_EXISTS
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: API_KEY_NOT_PROVIDED, INVALID_API_KEY, UNAUTHENTICATED
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: USER_DISABLED, NO_ACTIVE_SUBSCRIPTION
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: STORE_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:
    StoreUpdate:
      properties:
        description:
          maxLength: 256
          minLength: 12
          type: string
        domain:
          $ref: '#/components/schemas/Domain'
        image:
          maxLength: 512
          minLength: 12
          type: string
        metadata:
          type: object
        name:
          maxLength: 32
          minLength: 4
          type: string
        position:
          minimum: 1
          type: integer
        template:
          enum:
            - PERSONALIZADO
            - N/A
          type: string
      type: object
      minProperties: 1
    Store:
      properties:
        createdAt:
          format: date-time
          type: string
        description:
          nullable: true
          type: string
        domain:
          nullable: true
          type: string
        id:
          format: uuid
          type: string
        image:
          nullable: true
          type: string
        metadata:
          nullable: true
          type: object
        name:
          type: string
        position:
          type: integer
        template:
          enum:
            - PERSONALIZADO
            - N/A
          type: string
        updatedAt:
          format: date-time
          type: string
      required:
        - id
        - name
        - position
        - template
        - createdAt
        - updatedAt
      type: object
    Error:
      properties:
        code:
          example: STORE_NOT_FOUND
          type: string
      required:
        - code
      type: object
    Domain:
      properties:
        type:
          enum:
            - CUSTOM
            - DEFAULT
          type: string
        value:
          maxLength: 75
          minLength: 8
          type: string
          pattern: ^(?:[a-z0-9-]+\.)*[a-z0-9-]+(\.[a-z]{2,})?$
      required:
        - type
        - value
      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.