Kinds & fields
The core generation engine supports 12 distinct kinds. Standalone document kinds (cpf, cnpj, cnh, pis, rg) produce an object containing value and optional formatted representations, while complex entity kinds return rich structured objects.
person
Realistic individual with valid documents, contact details, and address matching the individual's location:
name(string): Full namefirstName(string): Given namelastName(string): Family namegender('F' | 'M'): Gender indicatorbirthDate(string): Birth date formatted asYYYY-MM-DDage(number): Calculated age in years relative tonowcpf(string): Valid CPF check digitsrg(string): SP identity document numbercnh(string): 11-digit DENATRAN driver license numberpis(string): 11-digit mod-11 PIS numbermotherName(string): Mother's full nameemail(string): Safe email address on an RFC 2606 domainmobilePhone(string): DDD matching address city +9+ 8 subscriber digitsphone(string): Landline phone (DDD +[2-5]+ 7 digits)address(object): Complete nestedaddressobject
company
Brazilian business entity with active tax numbers, partners, and CNAE activity:
corporateName(string): Legal entity name (Razão Social)tradeName(string): Commercial name (Nome Fantasia)cnpj(string): Valid CNPJ branch0001stateRegistration(string): State tax registration (Inscrição Estadual)municipalRegistration(string): Municipal registration (Inscrição Municipal)openingDate(string): Formation date formatted asYYYY-MM-DDsize('MEI' | 'ME' | 'EPP' | 'DEMAIS'): Company sizeactivity(object):{ cnae: string, description: string }email(string): Company contact emailphone(string): Landline phonemobilePhone(string): Mobile phonewebsite(string): Domain formathttps://www.slug.example.comaddress(object): Company addresspartners(array): 1 to 3personobjects (minimum age 21, matching state)
address
Postal address with verified Brazilian postal code (CEP) range and IBGE code:
postalCode(string): 8-digit postal code within the city's assigned rangestreet(string): Street type and namenumber(string): Building number (or'S/N')complement(string): Apartment, suite, room, or emptydistrict(string): Neighborhood name (Bairro)city(string): Municipality namestate(string): 2-letter state abbreviation (UF)stateName(string): Full state nameibgeCode(string): Official 7-digit IBGE city codecountry(string):'Brasil'
credit-card
Test credit card details with expiration dates in the future:
holderName(string): Cardholder namenumber(string): 16-digit card number (4444444444444444forAPPROVE,5184019740373151forDECLINE, or random Luhn-valid)brand(string): Card network (Visa, Mastercard, Elo, Amex)expiryMonth(string): 2-digit month (01–12)expiryYear(string): 4-digit expiration year (1 to 6 years ahead ofnow)ccv(string): 3-digit security codeoutcome('APPROVE' | 'DECLINE' | 'UNKNOWN'): Configured transaction result
bank-account
Bank account with verified Brazilian clearing codes:
bank(object):{ code: string, name: string, ispb: string }agency(string): 4-digit branch codeagencyDigit(string): Branch check digitaccount(string): Account numberaccountDigit(string): Account check digittype('CONTA_CORRENTE' | 'CONTA_POUPANCA'): Account type
pix-key
Pix identification key:
type('CPF' | 'CNPJ' | 'EMAIL' | 'PHONE' | 'EVP'): Key categorykey(string): Generated key value (UUIDv4 for EVP, E.164 format for phone)
charge
Financial invoice or charge for payment processing:
billingType('PIX' | 'BOLETO' | 'CREDIT_CARD'): Payment methodvalueCents(number): Total amount in centavosvalue(number): Amount in BRL with 2 decimal placesdueDate(string): Due date between 0 and 30 days afternowdescription(string): Line-item service or product descriptionexternalReference(string): Unique identifier prefixed withGEN-
Document Kinds (cpf, cnpj, cnh, pis, rg)
Stand-alone document generations produce:
value(string): Digits-only string (SP RG check digit may be'X')formatted(string, optional): Masked string whenformatted=true(e.g.123.456.789-09)
Query parameters
The GET /v1/:kind endpoint accepts the following query parameters:
| Parameter | Type & Default | Description |
|---|---|---|
count |
Integer (1–1000, default 1) |
Number of items to generate. Values outside range are automatically clamped. |
seed |
String (default random) | Seed for the deterministic PRNG. Same seed produces identical items. |
formatted |
Boolean (default false) |
When true, applies standard punctuation and masks to documents, phones, and CEPs. |
state |
String (2-letter UF) | Restricts generated address, DDD, and registration numbers to the specified state (e.g. SP, RJ, MG). |
gender |
'F' | 'M' |
Specifies name list and gender for person kind. |
outcome |
'APPROVE' | 'DECLINE' | 'RANDOM' |
Applies to credit-card. APPROVE yields 4444..., DECLINE yields 5184..., and RANDOM produces Luhn-valid card numbers. |
billingType |
'PIX' | 'BOLETO' | 'CREDIT_CARD' |
Forces payment method for charge kind. |
now |
Date / YYYY-MM-DD |
Reference date for age calculation, card expiration, and charge due dates. Defaults to current server time. |
Determinism
All core generation functions use an internal mulberry32 pseudo-random number generator initialized from the provided seed string. There is no call to Math.random() inside the core generation modules.
Given identical inputs (kind, seed, parameters, and reference date now), the output is guaranteed to be 100% identical. This makes the generator ideal for end-to-end regression suites, reproducible snapshot tests, and deterministic database fixtures.
Safe data guarantees
Generated data is designed never to collide with real-world credentials or deliver emails to unintended recipients:
- RFC 2606 Domains: All email addresses use reserved testing domains (
example.com,example.org,example.net). - Websites: Formatted with RFC 2606 domains as
https://www...example.com - Test Cards: Approvals and declines use the well-known test card numbers accepted by the Asaas mock (
4444444444444444and5184019740373151). - Phone numbers: Adhere to telecommunication standards without repeated subscriber digits, preventing spam flags during automated tests.
Asaas population
The POST /_mock/asaas/populate endpoint populates the Asaas mock server with customers and payments in a single operation.
Automatic Discovery Both Ways
The Asaas mock looks for the generator on boot and every 10 s at the compose service generator (or generator-mock), on this machine (localhost) and on the Docker host (host.docker.internal), port 45450, the closest first, and takes a place only when it answers GET /health with service: "generator". When GENERATOR_URL is set, it is used as given; set empty, it is turned off. GENERATOR_UI_URL (default http://localhost:45450) specifies where the browser opens it.
The generator finds the Asaas mock by itself when ASAAS_URL is unset: it probes asaas, asaas-mock, localhost, and the Docker host on port 45445, identified by its /health endpoint, on boot and every 10 s. Thus, running both via docker run or within any Docker Compose setup requires no URL environment variables.
The Panel Integration
While the generator is found, the Asaas panel displays an Integrations › Generator tab showing connection status, an "Open generator" link, and a "Populate this account" button. Clicking it creates customers (people and companies with valid CPF/CNPJ) for the account selected in the topbar, registers charges by Pix, boleto, and card, and marks a configurable share of them as paid. This executes through that account's API key via POST /_admin/generator/populate. When the generator is not found or turned off, the tab does not exist.
Request Body
{
"people": 5,
"companies": 2,
"chargesPerCustomer": 2,
"billingTypes": ["PIX", "BOLETO", "CREDIT_CARD"],
"confirm": 0.5,
"seed": "optional-seed",
"apiKey": "optional-account-api-key"
}Execution Steps
- Target Account: Uses the
apiKeyspecified in the request body to authenticate against Asaas, defaulting to the server's configuredASAAS_API_KEYif omitted. - Create Customers: For each person and company generated, issues a
POST /v3/customersrequest to the Asaas mock API. - Create Payments: For each customer, creates charges using
POST /v3/paymentsmatching the specifiedchargesPerCustomerandbillingTypes. - Confirm Payments: Based on the
confirmratio (0.0 to 1.0), issuesPOST /v3/sandbox/payment/{id}/confirmto transition selected charges from pending to confirmed/received status. - Report Results: Returns an array of customer IDs, payment records with invoice links, and an
errorsarray listing any failed steps with status codes and error messages.
Configuration
The generator server is configured via environment variables:
| Variable | Default | Description |
|---|---|---|
PORT |
45450 |
Port the HTTP server listens on. |
GENERATOR_ENABLED |
1 |
In Docker Compose, controls service replicas (deploy.replicas). Set GENERATOR_ENABLED=0 in .env to keep the service down. |
ASAAS_URL |
(unset: found by itself) | Base URL of the target Asaas mock service for population requests. When unset, discovered automatically (asaas, asaas-mock, localhost, Docker host on port 45445). Set to pin a URL; set empty to turn off. |
ASAAS_API_KEY |
$aact_hmlg_local_master |
Default API key used to authenticate customer and charge creation in Asaas. Can be overridden per request via apiKey in the populate body. |
ASAAS_PANEL_URL |
http://localhost:45445 |
Browser-accessible URL for the Asaas simulator panel (used in response links). |
ASAAS_SEED_ON_BOOT |
"" |
Specifies auto-population parameters on container startup (e.g. people=10,companies=3,charges=2,confirm=0.5). Stays off unless set. In the repository's root compose, mapped from GENERATOR_ASAAS_SEED_ON_BOOT. |
MOCK_ALLOWED_HOSTS |
"" |
Comma-separated list of additional host header values allowed by the local guard. |
Docker Compose
In another project's compose, add a generator service next to asaas. Both find each other automatically by service name without requiring any configuration variables:
generator:
image: ghcr.io/instituto-ama/generator-mock:0.2.0
ports:
- '45450:45450'
depends_on:
- asaasLocal guard
To prevent unauthorized access or cross-site request attacks against developer environments, the server enforces a Host and Origin security guard on the root UI route (/) and mock management endpoints (/_mock/*).
Allowed hosts default to localhost, 127.0.0.1, ::1, and host.docker.internal. On POST requests, the Origin header is validated against the permitted origins. Public API endpoints under /v1/* remain unrestricted with Access-Control-Allow-Origin: *.