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

# Crear Tienda

> Aprenda a crear una nueva tienda en su cuenta usando el endpoint POST /stores.

## 🏗️ Crear Tienda

Este endpoint permite **crear una nueva tienda** asociada a su cuenta.

Es ideal para:

* Provisionar tiendas automáticamente
* Crear tiendas en flujos de onboarding
* Integrar CRMs y sistemas externos con caBRAPI

## 🔐 Autenticación

Esta ruta **requiere autenticación** mediante **API Key**, enviada en el header de la solicitud:

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

## 📥 Body de la Solicitud

| Campo | Tipo | Obligatorio | Descripción |
| - | - | - | - |
| `template` | `string` | Sí | Valores aceptados: `PERSONALIZADO` o `N/A`. |
| `name` | `string` | No | Nombre de la tienda (mín. 4, máx. 32). |
| `description` | `string \| null` | No | Descripción de la tienda (mín. 12, máx. 256). |
| `image` | `string \| null` | No | URL de la imagen de la tienda (mín. 12, máx. 512). |
| `metadata` | `object \| null` | No | Metadatos personalizados de la tienda. |
| `domain` | `object \| null` | Condicional | Obligatorio cuando `template = PERSONALIZADO`. |

### Estructura de `domain`

| Campo | Tipo | Obligatorio | Descripción |
| - | - | - | - |
| `type` | `string` | Sí | Valores aceptados: `CUSTOM` o `DEFAULT`. |
| `value` | `string` | Sí | Dominio o subdominio (mín. 8, máx. 75). |

## 📋 Ejemplo de Solicitud

```bash theme={null}
curl --location "https://api.cabrapi.com.br/v1/stores" \
--header "Authorization: TU_API_KEY_AQUI" \
--header "Content-Type: application/json" \
--data '{
	"name": "Minha Loja",
	"description": "Loja oficial da minha marca",
	"image": "https://example.com/store.png",
	"template": "PERSONALIZADO",
	"domain": {
		"type": "DEFAULT",
		"value": "minha-loja"
	}
}'
```

## 📊 Ejemplo de Respuesta (201)

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

## ❌ Posibles Errores

| Status | Code | Cuándo ocurre |
| - | - | - |
| `400` | `INVALID_DATA` | Body JSON inválido o ningún campo enviado. |
| `400` | `INVALID_DATA_NAME_MIN` | `name` tiene menos de 4 caracteres. |
| `400` | `INVALID_DATA_NAME_MAX` | `name` tiene más de 32 caracteres. |
| `400` | `INVALID_DATA_DESCRIPTION_MIN` | `description` tiene menos de 12 caracteres. |
| `400` | `INVALID_DATA_DESCRIPTION_MAX` | `description` tiene más de 256 caracteres. |
| `400` | `INVALID_DATA_IMAGE` | `image` fuera del rango permitido (12 a 512 caracteres). |
| `400` | `INVALID_DATA_TEMPLATE` | `template` ausente o distinto de `PERSONALIZADO` y `N/A`. |
| `400` | `INVALID_DATA_DOMAIN` | `domain.type` distinto de `CUSTOM`/`DEFAULT` o `domain.value` inválido (8 a 75 caracteres). |
| `400` | `DOMAIN_REQUIRED` | `template` es `PERSONALIZADO` y no se envió `domain`. |
| `400` | `DOMAIN_ALREADY_EXISTS` | El dominio ya está siendo usado por otra tienda. |
| `400` | `NAME_ALREADY_EXISTS` | Ya existe una tienda con ese nombre para el mismo usuario. |
| `401` | `API_KEY_NOT_PROVIDED` | Header `Authorization` no enviado. |
| `401` | `INVALID_API_KEY` | API Key inválida o no encontrada. |
| `401` | `UNAUTHENTICATED` | Sesión/usuario no autenticado en el contexto de la solicitud. |
| `403` | `USER_DISABLED` | Cuenta de usuario desactivada o eliminada. |
| `403` | `NO_ACTIVE_SUBSCRIPTION` | Cuenta sin plan activo. |
| `403` | `STORE_LIMIT_REACHED` | Se alcanzó el límite de tiendas del plan. |
| `429` | `RATE_LIMIT_EXCEEDED` | Límite de solicitudes por minuto del plan excedido. |
| `500` | `INTERNAL_SERVER_ERROR` | Fallo interno al procesar la solicitud. |
| `503` | `SERVICE_UNAVAILABLE` | Servicio temporalmente no disponible. |

## 🔗 Enlaces Útiles

* [Documentación de Autenticación](https://docs.cabrapi.com.br/pages/es/api-reference/authorization.md)
* [Buscar Tiendas](https://docs.cabrapi.com.br/pages/es/api-reference/store/get.md)
* [Obtener Tienda por ID](https://docs.cabrapi.com.br/pages/es/api-reference/store/get-by-id.md)
* [Actualizar Tienda](https://docs.cabrapi.com.br/pages/es/api-reference/store/put.md)
* [Eliminar Tienda](https://docs.cabrapi.com.br/pages/es/api-reference/store/delete.md)

Update: 28/02/2026 as 00:00


## OpenAPI

````yaml POST /stores
openapi: 3.1.0
info:
  title: caBRAPI
  version: 1.0.0
servers:
  - url: https://api.cabrapi.com.br/v1
security: []
paths:
  /stores:
    post:
      tags:
        - Stores
      summary: Create store
      operationId: createStore
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StoreInput'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: STORE_CREATED
                    type: string
                  store:
                    $ref: '#/components/schemas/Store'
                required:
                  - code
                  - store
                type: object
          description: Store created.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: >-
            INVALID_DATA, 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, STORE_LIMIT_REACHED
        '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:
  schemas:
    StoreInput:
      properties:
        description:
          maxLength: 256
          minLength: 12
          type: string
          nullable: true
        domain:
          $ref: '#/components/schemas/Domain'
          nullable: true
        image:
          maxLength: 512
          minLength: 12
          type: string
          nullable: true
        metadata:
          nullable: true
          type: object
        name:
          maxLength: 32
          minLength: 4
          type: string
        template:
          enum:
            - PERSONALIZADO
            - N/A
          type: string
      required:
        - template
      type: object
    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.