通过FlowDeck REST API与FlowDeck CRM API交互,管理客户、交易、提案、应收账款、费用和联系人。用于所有CRM操作。
Interact with the FlowDeck CRM module via the REST API gateway
(base URL: https://<supabase_url>/functions/v1/api-gateway).
Run the script using the absolute path (do NOT cd to the skill directory):
bash
uv run ~/.codex/skills/flow-crm/scripts/flow_api.py <action> <resource> [options]
Important: Always run from the user's current working directory so any output files are saved where the user is working.
ActionDescriptionExamplelistList resources (paginated)uv run ... list clients --limit 50``getGet single resourceuv run ... get clients --id <uuid>``createCreate resourceuv run ... create clients --data '{"name":"Acme"}'``updateUpdate resourceuv run ... update clients --id <uuid> --data '{"name":"Acme Inc"}'``deleteDelete resourceuv run ... delete clients --id <uuid>
When creating a client ( create clients), the API only requires name. However, you MUST proactively ask the user about every available field BEFORE calling the API. Collect as much data as possible, then build the payload. Even if the user skips many fields, you must have asked.
Ask about these fields (use the Portuguese/Portuñol terms the user will recognize):
client, supplier, or both (default: client)finance_email)country)city_ibge_codeactive, inactive, or lead (default: active)Present these as a single structured block of questions (not one-by-one), e.g:
Antes de criar o cliente, preciso preencher algumas informações. Me diga o que souber:
- Tipo: [client/supplier/both]
- Empresa:
- Email:
- Email financeiro:
- Telefone:
- CPF/CNPJ:
- Website:
- Endereço:
- País:
- Código IBGE:
- Observações:
(Pule os que não souber.)
If the user responds with partial data, use what they gave and leave the rest blank — but never skip asking first. Then build the --data JSON with all collected fields and create the client.
ResourceEndpointNotesclients``/clientsClients & suppliers (finance_parties)contacts``/projects/{id}/contactsProject-scoped contactsdeals``/dealsCRM opportunities (crm_deals)proposals``/proposalsCommercial proposalsreceivables``/receivablesAccounts receivableexpenses``/expensesExpenses
list#Common query parameters (supported varies by resource):
--limit N (default 50, max 200)--offset N (default 0)--status — filter by status enum--type — filter by type (clients: client/supplier/both)--stage — filter by deal stage (deals: lead/qualified/proposal/negotiation/won/lost)--party-id — filter by client/supplier (party UUID)--project-id — parent project ID for scoped resources (contacts, cycles, tasks)--priority — filter task priority--cycle-id — filter tasks by cycle--assignee-id — filter tasks by assignee--due-date-from / --due-date-to — date range for receivables--date-from / --date-to — date range for expensesactive, inactive, lead
lead -> qualified -> proposal -> negotiation -> won / lost
draft -> sent -> viewed -> accepted / rejected / expired
pending, paid, partial, overdue, cancelled
pending, paid, partial
The script checks for API key in this order:
--api-key argument (use if user provided key in chat)FLOWDECK_API_KEY environment variableIf neither is available, the script exits with an error message.
FLOWDECK_API_KEY — Bearer API keyFLOWDECK_BASE_URL — API base URL (default: https://mycivgjuujlnyoycuwrz.supabase.co/functions/v1/api-gateway)command -v uv (must exist)test -n "$FLOWDECK_API_KEY" (or pass --api-key)Error: No API key provided. → set FLOWDECK_API_KEY or pass --api-keyHTTP 401 → invalid/revoked keyHTTP 404 → resource not found or doesn't belong to workspace"quota/permission/403" → wrong key, no access, or quota exceededList active clients:
bash
uv run ~/.codex/skills/flow-crm/scripts/flow_api.py list clients --status active --limit 20
Create a deal:
bash
uv run ~/.codex/skills/flow-crm/scripts/flow_api.py create deals \
--data '{"title":"Website Redesign","client_id":"<uuid>","value":50000,"stage":"lead"}'
Create a proposal:
bash
uv run ~/.codex/skills/flow-crm/scripts/flow_api.py create proposals \
--data '{"title":"Proposta — Website Redesign","client_id":"<uuid>","deal_id":"<uuid>","currency":"BRL"}'
Update a deal stage to won:
bash
uv run ~/.codex/skills/flow-crm/scripts/flow_api.py update deals \
--id <uuid> --data '{"stage":"won"}'
List overdue receivables for a client:
bash
uv run ~/.codex/skills/flow-crm/scripts/flow_api.py list receivables \
--status overdue --party-id <uuid>