Skip to main content
POST
/
api
/
profiles
Create Profile
curl --request POST \
  --url https://api.example.com/api/profiles \
  --header 'Content-Type: application/json' \
  --data '
{
  "nombre": "<string>",
  "rfc": "<string>",
  "tipo_persona": "<string>",
  "regimenes_fiscales": [
    {}
  ],
  "validaciones_habilitadas": {}
}
'
{
  "message": "<string>",
  "data": {
    "id": "<string>",
    "user_id": "<string>",
    "nombre": "<string>",
    "rfc": "<string>",
    "tipo_persona": "<string>",
    "regimenes_fiscales": [
      {}
    ],
    "validaciones_habilitadas": {},
    "frozen": true,
    "frozen_reason": "<string>",
    "frozen_at": "<string>",
    "created_at": "<string>",
    "updated_at": "<string>"
  }
}
Create a new profile for the authenticated user.

Authentication

This endpoint requires Bearer token authentication. Include the JWT token in the Authorization header.
Authorization: Bearer <your_token>

Request Body

nombre
string
required
Profile nameValidation:
  • Required field
  • Minimum length: 2 characters
  • Maximum length: 255 characters
  • Will be trimmed of whitespace
rfc
string
required
Mexican tax ID (RFC)Validation:
  • Required field
  • Must match RFC format: ^[A-Z&Ñ]{3,4}\d{6}[A-V1-9][A-Z1-9][0-9A]$
  • Case-insensitive (will be normalized to uppercase)
  • Must be unique across all users (one RFC per Contafy account)
  • Will be trimmed of whitespace
tipo_persona
string
required
Type of person/entityAllowed values:
  • FISICA - Individual person
  • MORAL - Company/Legal entity
regimenes_fiscales
array
Array of tax regime codes (SAT format)Validation:
  • Must be an array of strings
  • Each element must be a non-empty string
  • Empty strings will be filtered out
  • Defaults to empty array [] if not provided
validaciones_habilitadas
object
Custom validation settingsValidation:
  • Must be a valid JSON object
  • Defaults to empty object {} if not provided

Response

Returns the created profile object.
message
string
required
Success message
data
object
required
Created profile object with all fields
id
string
required
Profile unique identifier (UUID)
user_id
string
required
Owner user ID (UUID)
nombre
string
required
Profile name
rfc
string
required
Normalized RFC (uppercase)
tipo_persona
string
required
Person type: FISICA or MORAL
regimenes_fiscales
array
required
Array of tax regime codes
validaciones_habilitadas
object
required
Custom validation settings
frozen
boolean
required
Always false for new profiles
frozen_reason
string
Always null for new profiles
frozen_at
string
Always null for new profiles
created_at
string
required
ISO 8601 timestamp of profile creation
updated_at
string
required
ISO 8601 timestamp of last update

Example Request

curl -X POST https://api.contafy.com/api/profiles \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "Mi Empresa S.A. de C.V.",
    "rfc": "EMP840101ABC",
    "tipo_persona": "MORAL",
    "regimenes_fiscales": ["601", "603"],
    "validaciones_habilitadas": {}
  }'

Example Response

{
  "message": "Perfil creado exitosamente",
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "user_id": "123e4567-e89b-12d3-a456-426614174000",
    "nombre": "Mi Empresa S.A. de C.V.",
    "rfc": "EMP840101ABC",
    "tipo_persona": "MORAL",
    "regimenes_fiscales": ["601", "603"],
    "validaciones_habilitadas": {},
    "frozen": false,
    "frozen_reason": null,
    "frozen_at": null,
    "fiel_cer_encrypted": null,
    "fiel_key_encrypted": null,
    "fiel_password_encrypted": null,
    "sat_download_last_sync_at": null,
    "sat_download_sync_enabled": false,
    "created_at": "2024-03-07T12:00:00.000Z",
    "updated_at": "2024-03-07T12:00:00.000Z"
  }
}

Error Responses

400 Bad Request
Validation errors in request body
{
  "errors": [
    {
      "field": "nombre",
      "message": "El nombre debe tener entre 2 y 255 caracteres"
    },
    {
      "field": "rfc",
      "message": "Formato de RFC inválido"
    },
    {
      "field": "tipo_persona",
      "message": "El tipo de persona debe ser FISICA o MORAL"
    }
  ]
}
401 Unauthorized
User is not authenticated or token is invalid
{
  "error": "Usuario no autenticado"
}
403 Forbidden
Profile limit reached for current plan
{
  "error": "Has alcanzado el límite de perfiles para tu plan FREE",
  "limit": 1,
  "current": 1,
  "code": "PROFILE_LIMIT_REACHED"
}
409 Conflict
RFC already in use by another user
{
  "error": "Este RFC ya está en uso",
  "message": "Este RFC ya está registrado en Contafy por otro usuario. Si requiere ayuda para resolver este problema, contacte a [email protected]",
  "code": "RFC_IN_USE"
}
500 Internal Server Error
Server error occurred while creating profile
{
  "error": "Error al crear perfil"
}

Important Notes

  • Each RFC can only exist once across all Contafy accounts
  • Profile limits depend on your subscription plan (FREE: 1, BASIC: 3, PRO: 10, ENTERPRISE: unlimited)
  • RFCs are automatically normalized to uppercase
  • Empty strings in regimenes_fiscales array are filtered out

Build docs developers (and LLMs) love