gigstack API
  1. Clients
gigstack API
  • Welcome to gigstack API
  • gigstack Connect API Guide
  • Migrar de API v1 a v2 de gigstack
  • Clients
    • Clients API Guide
    • List clients
      GET
    • Get client
      GET
    • Update client
      PUT
    • Create client
      POST
    • Validate client fiscal information
      POST
    • Get client customer portal access token
      POST
    • Stamp pending receipts
      POST
    • Delete client
      DELETE
    • Upload CSF PDF to create or update client
      POST
  • Services
    • Services API Guide
    • List services
      GET
    • Get service
      GET
    • Update service
      PUT
    • Create service
      POST
    • Delete service
      DELETE
  • Invoices
    • Invoices API Guide
    • Income
      • List income invoices
      • Get income invoice
      • Create income invoice
    • Egress
      • List egress invoices
      • Get egress invoice
      • Create egress invoice
    • List CFDI errors
      GET
    • List payment complement invoices
      GET
    • Get payment complement invoice
      GET
    • Get invoice files
      GET
    • Cancel invoice
      DELETE
  • Payments
    • Payments API Guide
    • List payments
    • Get payment
    • Request payment
    • Register payment
    • Mark payment as paid
    • Refund payment
    • Cancel payment
    • Search payments
  • Receipts
    • Receipts API Guide
    • List receipts
    • Get receipt
    • Create receipt
    • Stamp receipt
    • Cancel receipt
  • Teams
    • Teams API Guide
    • List teams
    • Get team
    • Get team integrations
    • Get team series
    • Get team onboarding URL
    • Update team
    • Update team series
    • Update team settings
    • Create team
    • Add team member
    • Remove team member
    • Create team series
    • Upload SAT CSD certificates
    • Sign manifest document
  • Users
    • Users API Guide
    • List users
    • Get user
    • Update user
    • Create user
    • Reset user password
    • Generate login link
  • Catalogs
    • Tax Regimes Catalog (Régimen Fiscal)
    • Payment Forms | Formas de pago
    • CFDI Usage Catalog (Uso CFDI)
    • Payment Methods Catalog (Método de Pago)
    • Months and Bimesters Catalog (Meses y Bimestres)
    • Invoice Relationships Catalog (Relación entre Facturas)
  • Webhooks
    • Webhooks
    • List webhooks
    • Create webhook
    • Get webhook
    • Update webhook
    • Delete webhook
  • Schemas
    • Schemas
      • ApiResponse
      • Category
      • Pet
      • Tag
      • Order
      • StandardizedSuccessResponse
      • StandardizedErrorResponse
      • ApiErrorCode
    • RequestBodies
      • UserArray
    • OrderDirection
    • ApiPublicClient
    • Client
    • DateRangeFilter
    • Service
    • ListQueryParams
    • ClientInput
    • ApiPublicService
    • ServiceInput
    • PaginationMeta
    • Invoice
    • InvoiceIncomeInput
    • Payment
    • PaymentInput
    • PaymentItem
    • InvoiceInput
    • InvoiceEgressInput
    • Team
    • PaymentAllowedMethod
    • TeamInput
    • TeamSettingsInput
    • CfdiError
    • ApiPublicPaymentProcessorDetails
    • User
    • ApiPublicPayment
    • UserInput
    • ClientAddress
    • TaxSchema
    • StandardSuccessResponse
    • RequestPaymentInput
    • RegisterPaymentInput
    • ListResponse
    • ErrorResponse
    • ApiPublicIncomeInvoice
    • ValidationErrorResponse
    • RefundPaymentInput
    • ApiPublicTeam
    • UnauthorizedError
    • MarkPaymentAsPaidInput
    • ApiPublicUser
    • NotFoundError
    • ApiPublicSearch
    • InternalServerError
    • ApiPublicThirdParty
    • ApiPublicInvoiceConfig
    • ApiPublicRefund
    • ApiPublicAutomations
    • TeamSettings
    • TaxElement
    • SeriesInput
    • Series
    • ApiPublicWebhook
    • ReceiptInput
    • WebhookInput
    • WebhookUpdateInput
    • PaymentMethodEnum
    • PaymentFormEnum
    • AutomationTypeEnum
    • ItemSchema
  1. Clients

Clients API Guide

Clients API Guide#

Manage clients with fiscal information for Mexican tax compliance. The Clients API handles customer data, RFC validation, EFOS checking, and SAT compliance requirements.

📋 Overview#

Clients are the foundation of your invoicing system. Each client contains fiscal information required for Mexican tax compliance, including RFC (tax ID), tax system, and address information.

🔑 Key Features#

RFC Validation - Automatic tax ID validation against SAT
EFOS Checking - Blacklist validation for compliance
Address Management - Mexican address structure support
Metadata Support - Custom fields for additional data
Duplicate Prevention - Search for existing clients before creating (upsert-like behavior)
Auto-creation - Create clients during invoice/payment flow

📚 Endpoints#

List Clients#

Retrieve a paginated list of clients with filtering and search capabilities.
Query Parameters:
limit (integer, 1-100) - Number of results per page (default: 10)
next (string) - Pagination cursor for next page
team (string) - gigstack Connect: Target team ID
Example Request:
Example Response:
{
    "message": "Clients retrieved successfully",
    "data": [
        {
            "id": "client_1234567890",
            "name": "Juan Pérez García",
            "company": "Empresa SA de CV",
            "email": "juan.perez@ejemplo.com",
            "tax_id": "PEGJ800101ABC",
            "tax_system": "601",
            "livemode": true,
            "created_at": 1677651234,
            "efos": {
                "is_valid": true
            }
        }
    ],
    "has_more": false,
    "total_results": 1
}

Create Client#

Create a new client with fiscal information.
Duplicate Prevention (Upsert): Use the search parameter to find existing clients before creating:
If a match is found and search.update is false (default): Returns the existing client without modifications (200).
If a match is found and search.update is true: Updates the existing client with the provided data and returns it (200).
If no match is found: Creates a new client (201).
If multiple matches are found: Returns a 409 Conflict error with the list of matching client IDs.
Request Body:
{
    "name": "Juan Pérez García",
    "company": "Empresa SA de CV",
    "email": "juan.perez@ejemplo.com",
    "phone": "+52 55 1234 5678",
    "tax_id": "PEGJ800101ABC",
    "tax_system": "601",
    "use": "P01",
    "legal_name": "Juan Pérez García",
    "address": {
        "country": "Mexico",
        "street": "Av. Insurgentes Sur",
        "exterior": "123",
        "interior": "4B",
        "neighborhood": "Del Valle",
        "municipality": "Benito Juárez",
        "city": "Ciudad de México",
        "state": "CDMX",
        "zip": "03100"
    },
    "metadata": {
        "custom_field": "value"
    },
    "search": {
        "on_key": "tax_id",
        "on_value": "PEGJ800101ABC",
        "update": false
    }
}
Search Parameters:
ParameterTypeDescription
on_keystringThe field to search on (e.g., tax_id, email, name)
on_valuestringThe value to match against the specified field
updatebooleanIf true and a match is found, update the existing client with the provided data. Default: false
Example Request (Simple):
Example Request (With Duplicate Prevention):
Response Codes:
CodeDescription
200Existing client found (when using search)
201Client created successfully
409Multiple clients match the search criteria

Get Client#

Retrieve a specific client by ID.
Example Request:

Update Client#

Update an existing client's information.
Example Request:

Delete Client#

Delete a specific client.
Example Request:

Validate Client#

Validate client's fiscal information against SAT.
Example Request:

Stamp Pending Receipts#

Stamp all pending receipts for a client.
Example Request:

Customer Portal Access#

Get access token for client customer portal.

🏗️ Client Structure#

Required Fields#

None - All fields are optional for maximum flexibility

Important Fields#

tax_id (string) - RFC for Mexican tax compliance
tax_system (string) - SAT tax system code (e.g., "601", "612")
use (string) - Default CFDI use code (e.g., "P01", "G03")
email (string) - Email for invoice delivery

Tax System Codes#

Common SAT tax system codes:
601 - General de Ley Personas Morales
612 - Persona Física con Actividades Empresariales
621 - Incorporación Fiscal
622 - Actividades Agrícolas, Ganaderas, Silvícolas y Pesqueras
623 - Opcional para Grupos de Sociedades
624 - Coordinados
625 - Régimen de las Actividades Empresariales con ingresos a través de Plataformas Tecnológicas
626 - Régimen Simplificado de Confianza

CFDI Use Codes#

Common CFDI use codes:
P01 - Por definir
G01 - Adquisición de mercancías
G02 - Devoluciones, descuentos o bonificaciones
G03 - Gastos en general
I01 - Construcciones
I02 - Mobiliario y equipo de oficina por inversiones
I03 - Equipo de transporte
I04 - Equipo de computo y accesorios
I05 - Dados, troqueles, moldes, matrices y herramental
I06 - Comunicaciones telefónicas
I07 - Comunicaciones satelitales
I08 - Otra maquinaria y equipo

🔍 Search and Duplicate Prevention#

The search parameter enables upsert-like behavior when creating clients. This is useful for integrations that may send the same client multiple times.

Direct Client Creation (POST /clients)#

{
    "name": "Juan Pérez García",
    "email": "juan.perez@ejemplo.com",
    "tax_id": "PEGJ800101ABC",
    "tax_system": "601",
    "search": {
        "on_key": "tax_id",
        "on_value": "PEGJ800101ABC",
        "update": false
    }
}

Within Invoices or Payments#

When creating invoices or payments, you can search for existing clients inline:
{
    "client": {
        "search": {
            "on_key": "tax_id",
            "on_value": "PEGJ800101ABC",
            "update": true
        },
        "name": "Juan Pérez García",
        "email": "juan.perez@ejemplo.com",
        "tax_id": "PEGJ800101ABC",
        "tax_system": "601"
    }
}

Search Behavior#

ScenarioResult
Single match found, update: falseReturns existing client unchanged
Single match found, update: trueUpdates client with provided data, returns updated client
No match foundCreates new client automatically
Multiple matches foundReturns 409 Conflict with list of matching client IDs

Example: Update Existing Client on Match#

This will find the client with tax_id: PEGJ800101ABC and update their email to nuevo.email@ejemplo.com.

🛡️ Validation and Compliance#

RFC Validation#

Automatic format validation
SAT registry verification

EFOS Checking#

Blacklist validation against SAT's EFOS list
Automatic status updates
Compliance reporting

Address Validation#

Mexican postal code verification
Address completeness checking

💡 Best Practices#

1.
Always include tax_id for Mexican clients
2.
Set appropriate tax_system based on client type
3.
Use metadata for custom business logic
4.
Validate clients before important transactions
5.
Keep addresses updated for compliance
6.
Use search functionality to avoid duplicates

🔗 Related Resources#

Invoices API - Create invoices for clients
Payments API - Process payments from clients
Teams API - Manage team settings that affect clients

🚨 Error Handling#

Common error scenarios:

Invalid RFC Format#

{
    "message": "Invalid tax_id format",
    "error": "RFC must be 12 or 13 characters"
}

Client Not Found#

{
    "message": "Client not found",
    "error": "The specified client does not exist"
}

EFOS Validation Failed#

{
    "message": "Client failed EFOS validation",
    "error": "Client is on SAT blacklist"
}

Multiple Clients Match Search Criteria (409 Conflict)#

When using the search parameter and multiple clients match the criteria:
{
    "success": false,
    "error": {
        "code": "resource_conflict",
        "message": "Multiple clients found matching tax_id=\"PEGJ800101ABC\". Please use a more specific search criteria.",
        "details": ["client_1234567890", "client_0987654321"]
    }
}
Resolution: Use one of the returned client IDs directly, or use a more specific search key (e.g., combine with email or use the client id directly).

Need help with client management? Check our support documentation or contact support@gigstack.io
Modified at 2025-12-12 21:28:12
Previous
Migrar de API v1 a v2 de gigstack
Next
List clients
Built with