Sales pipeline and deals
The sales pipeline tracks each opportunity as a deal that moves through stages. Through the API you create the deal, update its fields and change its stage. The rest happens in Faturei Hoje.
The typical use is this: your system sends each customer to the pipeline and the automations take care of the follow-up. You say which stage the customer is in (signed up, trying it out, trial ending, became a customer), and the sequence configured in the dashboard for that stage sends the message, opens a task for someone on the team, or both. When the deal changes stage, whatever was waiting for the previous stage is canceled and the sequence of the new stage starts.
The key
Section titled “The key”| Permission | What for |
|---|---|
pipelines:read | Read pipelines and stages, to get the ids |
deals:create | Create the deal |
deals:update | Update the deal and change its stage |
deals:read | Read deals and loss reasons |
leads:create | Optional. To register the client before the deal |
The member the key acts as needs access to the CRM in the dashboard. See Permissions.
The pipeline ids
Section titled “The pipeline ids”GET /public/v1/pipelines returns each pipeline with its stages. Each stage has id, name and kind: open is a stage in progress, won is won and lost is lost. Pipelines rarely change: read once and keep the ids.
You can also create the pipeline through the API, with POST /public/v1/pipelines. It needs at least one open stage.
Create the deal
Section titled “Create the deal”curl -X POST "https://api.fatureihoje.com/public/v1/deals" \ -H "Authorization: Bearer $FH_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "title": "Padaria Sol", "pipeline_id": "0b8f7c1e-2a3d-4e5f-8a9b-1c2d3e4f5a6b", "client_id": "7d2e9f4a-6b1c-4d3e-9f8a-5b6c7d8e9f0a", "value_cents": 10787, "source": "website-signup", "custom_fields": { "plano": "start", "fim_do_teste": "2026-10-15" } }'- Without
stage_id, the deal enters the first open stage of the pipeline. client_idis optional and comes fromGET /public/v1/clientsor from thelead.idofPOST /public/v1/leads, which registers without duplicating.value_centsis the value in cents.custom_fieldsholds whatever belongs to your system: lowercase keys with_, values that are text, number or boolean. Each key becomes thecampo_<key>variable in automation messages.
The response is 201 with the deal. Keep the id: you use it to update and move the deal later.
To update fields, use PATCH /public/v1/deals/{id} with only what changed. custom_fields is merged with the current fields, and a null value removes the key.
Move to another stage
Section titled “Move to another stage”curl -X POST "https://api.fatureihoje.com/public/v1/deals/$DEAL_ID/stage" \ -H "Authorization: Bearer $FH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "stage_id": "3c5d7e9f-1a2b-4c3d-8e9f-0a1b2c3d4e5f" }'The response is 200 with the deal in the new stage. Winning and losing are the same call: move to a won or lost stage. On a lost stage you can send lost_reason_id (from GET /public/v1/deal_loss_reasons) and lost_note. Moving back to an open stage reopens the deal.
Moving to the stage the deal is already in does nothing and answers 200, so repeating the call is safe.
Know what changed
Section titled “Know what changed”The deal.created, deal.updated, deal.stage_changed and deal.deleted webhooks tell your system when someone touches the deal in the dashboard. See Webhooks.
When the call fails
Section titled “When the call fails”| Response | What to do |
|---|---|
404 resource_not_found | The deal, pipeline or stage does not exist in this organization. Check the id |
422 validation_failed | Invalid field, or a client, owner or reason that is not from this organization |
403 permission_missing | The key lacks the permission |
403 member_permission_denied | The member behind the key has no access to the CRM in the dashboard |
| 429 or 5xx | Retry. On POST /deals, with the same Idempotency-Key |
The full catalog is in Errors.