---
title: "Your First Customer Account in Test"
description: "Open a synthetic customer account for one of your customers from the dashboard, wait for the sandbox to open it, and charge into it with Collect by naming its consumer_id."
---

import { Callout } from "fumadocs-ui/components/callout";

<MetaStrip items={[
  { label: "TIME", value: "~30 min" },
  { label: "WHERE", value: "Dashboard, then curl" },
  { label: "ENVIRONMENT", value: "Test" },
]} />

Give one of your customers an account of their own in a Test project: from a
company organization to a customer account the sandbox opened, ready to receive
a Collect charge. The [Spaces concept](/docs/concepts/spaces) explains the model;
this page is the click path.

<Callout type="info" title="The dashboard speaks Portuguese">
The dashboard is in Portuguese. Every label below is quoted exactly as the
dashboard shows it, in bold and quotes, followed by what it means.
</Callout>

## Prerequisites

- **A company organization (PJ).** Spaces is for organizations declared PJ.
- **The titular.** The person who created the organization. Only the titular, with
  the Owner or Admin role in the project, sees and opens customer accounts.
- **A Test project whose sandbox access is active.** The platform prepares it by
  itself, for every organization. The next section says how to tell.
- For the last step, an API key of that Test project with `collect:read` and
  `collect:write` (a key created without a scope list has both), and Collect
  available in the project ([Collect](/docs/concepts/collect) is in early access).

## Before you start: the project's sandbox access

In Test, the Space needs no activation and no request, and there is nothing to
ask CodeSpar for: the platform prepares the Test project's sandbox access by
itself, for every organization, in seconds.

Open **"Spaces"** with the header toggle **"Modo de teste"** (Test mode) on, and
read the card **"Acesso do projeto ao sandbox"** (the project's sandbox access)
below the list:

| The dashboard shows | What it means | What to do |
|---|---|---|
| **"ativo"** | Active: you can open customer accounts | Go to step 1 |
| **"preparando"** | Being prepared. The page checks again every 5 seconds, with no end | Wait: it takes a few seconds. If it is still preparing after about a minute, contact CodeSpar (see below) |
| **"Preparando o acesso do projeto ao sandbox. Isso leva alguns segundos, e a tela atualiza sozinha."** | Same, in the empty list | Same: past about a minute, contact CodeSpar |
| **"pedido"**, **"suspenso"**, **"revogado"**, **"expirado"** or **"não ativo"** | Requested, suspended, revoked, expired or not active | Contact CodeSpar with your organization and project |
| No **"Criar conta de cliente"** button, and the empty list says **"Nenhum cliente deste projeto tem conta aberta no sandbox sem conta de cliente."** | Rare: access is active, but opening new customer accounts is not available for your organization | Contact CodeSpar with your organization and project |
| **"A abertura de contas de teste para clientes ainda não está disponível nesta conta."** (`409 customer_account_opening_unavailable`, after pressing the button) | The same rare case | Contact CodeSpar with your organization and project |

<Callout type="info" title='Stuck on "preparando"'>
Past about a minute on **"preparando"**, the access is not going to finish by
itself, and the page keeps checking with no end. Contact CodeSpar through
[support](/docs/support), naming the organization and the Test project.
</Callout>

## 1. Create the organization as a company

Sign up at [codespar.dev/auth/signup](https://codespar.dev/auth/signup). Choose
**"Empresa"** (company) as the account type, fill **"Razão social"** (the legal
name), press **"Criar conta da empresa"** and confirm the code sent to your
email.

Creating the organization this way records you as its titular. Your account
starts with a Test project.

<Callout type="info">
An organization created as a person (PF) sees the **"Spaces"** item locked, with
the upgrade path **"Ver o que muda na PJ"**. An older organization with no
titular on record shows a card on the Spaces page: the person who created it,
if still Owner or Admin, ticks the confirmation box and then presses
**"Confirmar que sou o titular"** to record themselves.
</Callout>

## 2. Open Spaces in Test mode

1. Turn on **"Modo de teste"** (Test mode) in the header, so the active project is
   your Test project.
2. In the sidebar group **"Empresa"**, open **"Spaces"**.

The page shows the title **"Spaces"** with the tag **"Modo de teste"**, the list
**"Contas de clientes"** (customer accounts) and the sandbox access card from
the section above. If you are not the titular, the list is replaced by
**"O painel de Spaces é visível só para o titular da conta."**: ask the titular.

## 3. Ask for a test account for your customer

Press **"Criar conta de cliente"** (create customer account) and fill:

| Field | What to type |
|---|---|
| **"Nome do cliente"** | Your customer's name, as you want to see it in the dashboard and in Collect (up to 120 characters) |
| **"Tipo"** | **"Pessoa física"** (a person) or **"Pessoa jurídica"** (a company) |
| **"Referência externa (opcional)"** | Your own key for this customer, to reconcile later. Unique in the project |

The dialog lists what happens before you send. The sandbox account is opened
with CodeSpar's synthetic data, never your customer's documents, and no money
moves. It also states the quota:
**"Usa a cota do projeto: 2 aberturas a cada 30 dias. Acima disso, o pedido espera."**

Press **"Pedir conta de teste"** (ask for a test account). The dashboard confirms:
**"Conta de teste pedida. Ela aparece como rascunho até o sandbox abrir a conta."**

If you see **"Só o titular, como Owner ou Admin, cria contas de clientes."**
instead of the button, you are the titular but your role in the organization is
not Owner or Admin. Someone who is not the titular never gets this far: they see
the titular-only card from step 2.

<Callout type="info">
When one of your customers already has an account open in the sandbox without a
customer account, the dialog also offers **"Cliente com conta aberta"** (customer
with an open account), which registers it without opening a new one.
</Callout>

## 4. Wait for the sandbox to open the account

Opening is asynchronous. The new row starts with status **"rascunho"** (draft),
and its column **"Onboarding no sandbox"** moves through:

| Onboarding column | Meaning |
|---|---|
| **"abertura pedida"** | Queued |
| **"em análise"** | The proposal was sent to the sandbox |
| **"concluído"** | The account is open and bound to the project |
| **"recusado"** with **"o sandbox recusou a proposta"** | The sandbox rejected the proposal; contact CodeSpar with the code shown |
| **"resultado incerto"** with **"nada foi reenviado; fale com a CodeSpar"** | The outcome is unknown and nothing was sent again; contact CodeSpar |
| **"parado"** with **"a abertura parou"** | The opening stopped; contact CodeSpar |

The sandbox checks the proposal on a schedule, so this can take from minutes to
longer. You do not need to keep the page open.

### The quota

A Test project reserves at most **2 proposals to the sandbox in 30 days**,
counted on a rolling window. The unit is a reserved proposal, not an opened
account:

- the project's own Test account uses one of the 2;
- a proposal the sandbox refuses after it was created keeps its slot;
- so, in practice, a new project opens **one** customer account in its first
  30 days.

The limit is the project's, whatever path opens the account: the dashboard, as
in this guide, counts exactly as any other path would. The sandbox also has a
daily limit across all organizations. Neither is a failure: the request waits
and continues by itself. The row says which one:

| The row shows | Meaning |
|---|---|
| **"não iniciado"** with **"teto do projeto atingido (2 aberturas em 30 dias); segue quando liberar"** | The project's 2 proposals in 30 days are used; it continues when the oldest one leaves the window |
| **"não iniciado"** with **"limite diário do sandbox atingido; segue no próximo dia"** | The sandbox's daily limit is used; it continues the next day |

The dashboard has no quota counter: the dialog states the rule, and the row shows
when a request is waiting for it.

## 5. Confirm the account is ready

The account is ready when its row reads status **"ativa"** (active) and onboarding
**"concluído"**. The column **"Conta no sandbox"** then shows the masked account.

To receive a Collect charge it also needs its Pix key, registered right after
the account opens when Collect is available in the project. Check it from your
code:

```bash
curl https://api.codespar.dev/v1/collect/receivers \
  -H "Authorization: Bearer $CODESPAR_API_KEY"
```

Find your customer by `label` (the name you typed in step 3). Ready to receive is
`"eligible": true`; `"not_ready": "pix_key_pending"` means the Pix key is still
being registered. Keep that entry's `consumer_id`.

Optional: as Owner or Admin you can add test balance to an active account with
**"Abastecer"** (top up) in its row, up to R$ 10.000,00 per top-up. From code,
`POST /v1/account/fund/sandbox` does the same with an API key holding the
`consumers:fund` scope (see the [account reference](/docs/api/reference/account)).
It is test balance in the sandbox, not real money.

## 6. Charge into the customer's account

Name the customer on the link with `consumer_id`, every time:

```bash
curl -X POST https://api.codespar.dev/v1/collect/links \
  -H "Authorization: Bearer $CODESPAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "consumer_id": "cus_000000000000000000000000",
    "version": {
      "title": "Order 4417",
      "items": [{ "name": "Monthly plan", "quantity": 1, "unit_amount_minor": 4990 }],
      "surfaces": ["page"],
      "due_in_days": 3
    }
  }'
```

A `201` here does not mean the receiver was accepted: creating the link does
not check it. An explicit `consumer_id` is checked when you publish the link,
and one that cannot receive is refused then, with `422 receiving_identity_missing`.

Without `consumer_id`, Collect chooses the receiver itself. With a default
receiver set, it uses that one, the same for every charge in the project (a
default that stopped being eligible is refused with
`409 collect_receiver_default_ineligible`). Without a default, it uses the only
eligible receiver when there is exactly one. The project's own Test account is
eligible too, so after this first customer account there are two, and an
unnamed link is refused with `409 collect_receiver_unresolved` (as it is with
zero). The [Spaces concept](/docs/concepts/spaces#always-pass-consumer_id)
explains why a default receiver is not the fix. Publishing and paying the link
in Test are in [Collect](/docs/concepts/collect).

Charging into a customer's own account is Test only today: in Live, a link
naming a consumer other than your organization's own account is refused with
`422 receiving_identity_missing`.

## Refusals, and which ones a retry fixes

| The dashboard says | Why | Does a retry fix it? |
|---|---|---|
| **"O painel de Spaces é visível só para o titular da conta."** | You are not the titular | No. The titular acts |
| **"Só o titular, como Owner ou Admin, cria contas de clientes."** | You are the titular, but your role in the organization is not Owner or Admin | No. Get the Owner or Admin role |
| **"O acesso do projeto ao sandbox ainda está sendo preparado. Nada foi criado; tente de novo em alguns segundos."** (`403 onboarding_capability_inactive`) | Sandbox access is not active yet | Yes, in a few seconds. If it persists past about a minute, contact CodeSpar through [support](/docs/support) |
| **"O acesso do projeto ao sandbox não está ativo. Nada foi criado."** (`403 onboarding_capability_inactive`) | Sandbox access is not active | No. Contact CodeSpar |
| **"A abertura de contas de teste para clientes ainda não está disponível nesta conta."** (`409 customer_account_opening_unavailable`) | Rare: onboarding is active, but opening new customer accounts is not available for your organization | No. Contact CodeSpar with your organization and project |
| **"Outra conta de cliente deste projeto já usa essa referência externa."** | The external reference is taken | No. Use another reference |
| A sentence saying this customer already has an open customer account in this project | A customer has at most one per project | No. Use the existing account |
| Any other refusal: a message that nothing was created, with an error code beside it | An unexpected error | Sometimes. Retry once, then contact CodeSpar with the code |

## Via the API: not yet

In a Test project, opening an account over the API is refused on purpose:

```text
POST /v1/account-applications  →  403 sandbox_onboarding_synthetic_only
```

It is a CodeSpar rule applied before anything reaches the partner: in Test, a
customer's account is opened only by CodeSpar's provisioning with synthetic data,
so a real CPF or CNPJ sent in a request is never used to open one. The routes the
dashboard uses for customer accounts (`/v1/spaces`) do not accept an API key, so
in Test this page is the way to open one.

## What this does not do

- **Live.** Real accounts, with real verification, are activated with the
  CodeSpar team and are not covered here.
- **Your customer's data.** In Test the account is opened with synthetic data, so
  the holder shown at the sandbox is not your customer.
- **Bulk import.** Customer accounts are opened one at a time, inside the quota.
- **Move a Test account to Live.** Test accounts stay in their Test project.

## Next steps

<NextStepsGrid items={[
  { label: "CONCEPT", title: "Spaces", description: "Organization, project, Space and customer account, and what runs where.", href: "/docs/concepts/spaces" },
  { label: "CONCEPT", title: "Collect", description: "Links, publishing and paying in Test.", href: "/docs/concepts/collect" },
  { label: "COOKBOOK", title: "Multi-Tenant Agent", description: "Session metadata per tenant, and where customer accounts come in.", href: "/docs/cookbooks/multi-tenant" },
]} />
