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

# Create Profile

> Create a new profile for managing CFDI invoices

## Authentication

This endpoint requires authentication using a JWT token in the Authorization header.

## Request Body

<ParamField body="nombre" type="string" required>
  Name of the profile or business entity
</ParamField>

<ParamField body="rfc" type="string" required>
  RFC (Registro Federal de Contribuyentes) - Mexican tax identification number. Must be valid according to SAT format rules.
</ParamField>

<ParamField body="tipo_persona" type="enum" required>
  Type of taxpayer entity:

  * `FISICA`: Individual taxpayer (Persona Física)
  * `MORAL`: Corporation or legal entity (Persona Moral)
</ParamField>

<ParamField body="regimenes_fiscales" type="string[]">
  Array of tax regime codes applicable to this profile. These are official SAT regime codes (e.g., "601", "603", "605").
</ParamField>

<ParamField body="validaciones_habilitadas" type="object">
  Configuration object for validation rules to enable for this profile

  <ParamField body="validarRFCIngresos" type="boolean">
    Validate RFC on income invoices
  </ParamField>

  <ParamField body="validarRFCGastos" type="boolean">
    Validate RFC on expense invoices
  </ParamField>

  <ParamField body="validarRegimenFiscal" type="boolean">
    Validate tax regime matches profile configuration
  </ParamField>

  <ParamField body="validarUUIDDuplicado" type="boolean">
    Check for duplicate invoice UUIDs
  </ParamField>

  <ParamField body="bloquearSiRFCNoCoincide" type="boolean">
    Block invoice processing if RFC doesn't match
  </ParamField>

  <ParamField body="bloquearSiRegimenNoCoincide" type="boolean">
    Block invoice processing if tax regime doesn't match
  </ParamField>
</ParamField>

## Response

<ResponseField name="message" type="string" required>
  Success message confirming profile creation
</ResponseField>

<ResponseField name="data" type="Profile" required>
  The created profile object

  <ResponseField name="id" type="string" required>
    Unique identifier for the newly created profile
  </ResponseField>

  <ResponseField name="user_id" type="string" required>
    ID of the user who owns this profile
  </ResponseField>

  <ResponseField name="nombre" type="string" required>
    Name of the profile or business entity
  </ResponseField>

  <ResponseField name="rfc" type="string" required>
    RFC (Registro Federal de Contribuyentes)
  </ResponseField>

  <ResponseField name="tipo_persona" type="enum" required>
    Type of taxpayer entity (`FISICA` or `MORAL`)
  </ResponseField>

  <ResponseField name="regimenes_fiscales" type="string[]" required>
    Array of tax regime codes
  </ResponseField>

  <ResponseField name="validaciones_habilitadas" type="object" required>
    Configuration object for validation rules
  </ResponseField>

  <ResponseField name="created_at" type="string" required>
    ISO 8601 timestamp of when the profile was created
  </ResponseField>

  <ResponseField name="updated_at" type="string" required>
    ISO 8601 timestamp of when the profile was last updated
  </ResponseField>

  <ResponseField name="frozen" type="boolean">
    Whether the profile is frozen
  </ResponseField>

  <ResponseField name="frozen_reason" type="enum">
    Reason why the profile is frozen
  </ResponseField>

  <ResponseField name="frozen_at" type="string | null">
    ISO 8601 timestamp of when the profile was frozen
  </ResponseField>
</ResponseField>

## Example Request

```bash theme={null}
curl -X POST https://api.contafy.com/api/profiles \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "Mi Empresa SA de CV",
    "rfc": "XAXX010101000",
    "tipo_persona": "MORAL",
    "regimenes_fiscales": ["601", "603"],
    "validaciones_habilitadas": {
      "validarRFCIngresos": true,
      "validarRFCGastos": true,
      "validarRegimenFiscal": false,
      "validarUUIDDuplicado": true,
      "bloquearSiRFCNoCoincide": false,
      "bloquearSiRegimenNoCoincide": false
    }
  }'
```

## Example Response

```json theme={null}
{
  "message": "Profile created successfully",
  "data": {
    "id": "prof_1234567890",
    "user_id": "user_0987654321",
    "nombre": "Mi Empresa SA de CV",
    "rfc": "XAXX010101000",
    "tipo_persona": "MORAL",
    "regimenes_fiscales": ["601", "603"],
    "validaciones_habilitadas": {
      "validarRFCIngresos": true,
      "validarRFCGastos": true,
      "validarRegimenFiscal": false,
      "validarUUIDDuplicado": true,
      "bloquearSiRFCNoCoincide": false,
      "bloquearSiRegimenNoCoincide": false
    },
    "created_at": "2024-03-04T16:30:00.000Z",
    "updated_at": "2024-03-04T16:30:00.000Z",
    "frozen": false
  }
}
```

## Error Responses

### 400 Bad Request

```json theme={null}
{
  "error": "Bad Request",
  "message": "Invalid RFC format"
}
```

### 401 Unauthorized

```json theme={null}
{
  "error": "Unauthorized",
  "message": "Invalid or missing authentication token"
}
```

### 403 Forbidden

```json theme={null}
{
  "error": "Forbidden",
  "message": "Profile limit reached for your current plan"
}
```

### 422 Unprocessable Entity

```json theme={null}
{
  "error": "Validation Error",
  "message": "Missing required field: nombre"
}
```

### 500 Internal Server Error

```json theme={null}
{
  "error": "Internal Server Error",
  "message": "An error occurred while creating the profile"
}
```
