---
name: luniumpay-custody
description: "Receber Pix em saldo em reais na LuniumPay (sem carteira fixa), separar por cliente com subcontas, sacar em cripto para qualquer rede do catálogo, pagar Pix com o saldo e transferir entre subcontas. Use quando o dono do app não tem carteira, quer acumular e sacar depois, opera marketplace/plataforma com vários clientes finais, ou precisa pagar fornecedores em Pix com o que recebeu. EN: Receive Pix into a BRL custody balance (no fixed wallet), per-customer sub-accounts, withdraw as crypto to any catalog network, pay Pix from the balance, internal transfers. Use for marketplaces/platforms or owners without a wallet."
license: MIT
metadata:
  version: "2.2.0"
  api: "1.45.2"
title: luniumpay-custody
canonical_url: https://skilld.dev/gh/luniumpay/lunium-agent-skills/luniumpay-custody
last_updated: 2026-10-26T17:05:31.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [.claude-plugin/plugin.json](https://skilld.dev/api/skills-raw/luniumpay/lunium-agent-skills/luniumpay-custody/.claude-plugin/plugin.json), [scripts/smoke-custody.mjs](https://skilld.dev/api/skills-raw/luniumpay/lunium-agent-skills/luniumpay-custody/scripts/smoke-custody.mjs).
>
> If the user asked to install this Skill, run `npx skilld install luniumpay/lunium-agent-skills/luniumpay-custody`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/luniumpay-custody`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/luniumpay/lunium-agent-skills/luniumpay-custody) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/luniumpay-custody`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/luniumpay-custody --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/luniumpay-custody --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Custódia: Pix entra em reais, sai como você quiser

Base `https://api.luniumpay.com`, header `X-API-Key`. Valores em centavos inteiros.

## Receber em saldo
`POST /cashin/charge` com `"destino": "saldo"`, `amount_cents`, `payer_tax_number`
(do pagador, dígito verificador validado no seu app), `external_id` e opcional `customer_ref`
(subconta = seu cliente final). Sem `asset`/`chain`/`payout_address`. QR e acompanhamento
iguais a `luniumpay-pix-charge`. Crédito líquido em `net_cents`; aparece em
`GET /saldo?customer_ref=…` quando `status=paid` e `settlement_status=sent`.

## Ler saldo
- `GET /saldo` (casa) ou `GET /saldo?customer_ref=cliente-42` → `disponivel_cents`,
  `bloqueado_cents`, `proximas_liberacoes[]` (`valor_cents`, `disponivel_em`), `em_carencia`,
  `carencia_ate`, `carencia_horas`, taxas de saque (`saque_fee_bps`, `saque_taxa_estimada_cents`,
  `saque_cripto_conversao_fee_bps`), `pix_rules` (teto por Pix).
- `GET /saldo/clientes` (subcontas paginadas), `GET /saldo/consolidado` (casa + clientes),
  `GET /saldo/extrato` (ledger ou operações agrupadas).

## Retenção: duas camadas, nenhuma é falha
1. **Faixa do pagador** (decidida na cobrança): `held: true`, `hold_hours`, `liberar_em` no
   `POST /cashin/charge` e no status; webhook `cashin.held`. Pagador estreante acima da faixa
   instantânea espera; o teto e a faixa sobem com o histórico (`GET /cashin/limits?payer_tax=`).
2. **Carência do saldo** (decidida no crédito): o valor entra em `bloqueado_cents` com data em
   `proximas_liberacoes[].disponivel_em` e `em_carencia: true`; webhooks `saldo.congelado` →
   `saldo.liberado`. Saque e payout usam só `disponivel_cents`.
Mostre a data de liberação ao dono, não peça outro Pix, não recrie a cobrança. Só a camada 2
aparece no sandbox (cenário `held`); a camada 1 só em produção.

## Sacar em cripto (sem teto comercial por valor)
`POST /saldo/sacar-cripto`:
```json
{"amount_cents": 50000, "asset": "usdt", "chain": "polygon",
 "payout_address": "<carteira do dono>", "tax_number": "<CPF/CNPJ do dono do saldo>",
 "customer_ref": "cliente-42", "external_id": "saque-2026-10-24-01",
 "max_debited_cents": 51500}
```
- `asset` minúsculo e `chain` conforme `GET /cashin/catalog` (aliases aceitos: `trc20`, `erc20`,
  `bep20`, `sol`, `base`…). `payout_tag` obrigatório em redes com memo (XRP, XLM, TON…),
  senão 400 `memo_obrigatorio`.
- `max_debited_cents` protege contra taxa maior que o esperado (409 `taxa_alterada`).
- Resposta: `debited_cents` (valor + taxa), `fee_cents`, `settlement_status`
  (`sending` → `sent`; `incerto` = conciliar, não repetir).
- Respeita saldo livre, mínimos da rota (`withdrawMin`) e carência; não herda o teto do Pix.

## Pagar Pix com o saldo (payout)
`POST /payouts` `{"amount_cents": 5000, "pix_key": "<chave>", "pix_key_type": "cpf",
"tax_number": "<CPF/CNPJ do recebedor>", "customer_ref": "cliente-42",
"external_id": "pg-fornecedor-77"}`
- Teto por Pix em `pix_rules.max_amount_cents` do `/saldo` (padrão R$ 6.000,00), sujeito a
  limites menores da conta. Débito ANTES do envio (valor + `saque_fee`). `tax_number`
  obrigatório com chave de e-mail, telefone ou aleatória; derivável de chave CPF/CNPJ.
- `GET /payouts/{id}` → `status` `pending` → `sent` (`e2e`, `verify_url`) · `failed`
  (`error`, saldo volta) · `refunded`. Histórico: `GET /payouts` → `payouts[]`.
- 11 dígitos: envie `pix_key_type` (`cpf` ou `phone`).

## Mover entre subcontas (sem Pix)
`POST /saldo/transferir` `{"from_customer_ref": "casa", "to_customer_ref": "cliente-42",
"amount_cents": 1000, "descricao": "bônus", "external_id": "tr-001"}`.

## Comissão do parceiro (se você revende)
`GET /comissao`, `GET /comissao/extrato`, `POST /comissao/sacar`. Comissão só sobre
operação liquidada; Pix retido, contestado ou devolvido nunca gera comissão.

## Webhooks
`cashin.paid` → `cashin.settled` (crédito), `cashin.held`, `saldo.congelado`, `saldo.liberado`,
`saldo.transferido`, `payout.sent|failed|refunded`.

## Sandbox
Cenários do saldo (`sandbox_scenario`): `success`, `delayed`, `held`, `expired`, `refunded`,
`failed`, `payer_mismatch`, `settlement_failed`, `settlement_uncertain`, `provider_unavailable`.
Payout: `success`, `delayed`, `failed`, `refunded`, `settlement_failed`, `settlement_uncertain`,
`provider_unavailable`. Saque cripto: `success`, `delayed`, `settlement_failed`,
`settlement_uncertain`, `route_unavailable`, `provider_unavailable`. Estado `incerto` fecha com
`POST /sandbox/operations/{cashin_id}/resolve` `{"outcome": "sent"}`. A escada por pagador fica
desligada no sandbox (teto fixo, sem `limite_do_pagador`).
Prova: `node scripts/smoke-custody.mjs` cobra em saldo, simula o Pix, mostra a carência do
cenário `held`, transfere, faz um payout e um saque em cripto, tudo fictício.
