Docs
OverviewPlatformPlatform APIA2P Messaging API
AI & MCP
Open dashboard
OverviewPlatformPlatform APIA2P Messaging API
AI & MCP
  • Overview
  • Introduction
  • Create an account
  • Choose your API
  • Authentication
  • AI & MCP
Product API
  • Guide
  • Quickstart
    • API tokens
    • Connected apps (OAuth)
    • Project readiness
    • Channel readiness
    • Senders
    • Attention
    • Recommendations
    • Overview
    • Contacts and attributes
    • Events
    • Query filter
    • Event query filter
    • Probes
    • Counting and retrieval
    • Segments
    • Overview
    • Creating a draft
    • Audience targeting
    • Message content
    • Dates and scheduling
    • Reading campaigns
    • Estimating and deleting
    • OverviewBeta
    • Templates
    • Creating and editing drafts
    • Triggers and exits
    • Nodes
    • Delays and waits
    • Overview
    • Statistics catalog
    • Building queries
    • Conversions & revenue
    • Reading results
    • Flow reports
    • Rate limits
    • Errors
  • Full API Reference
Ingest API
  • Guide
  • Quickstart
  • Authentication
  • Rate limits
  • Errors
  • Best practices
  • Full API Reference
Further reading
  • Query Filter
DashboardSupportinstasent.com

Platform API · Product API · Flows

Creating and editing drafts

The draft contract of a flow: creating a flow with its first draft, reading the draft back, replacing it whole with an expectedDraftId precondition, and validating a graph without saving it. Includes the response shapes, validation errors and advice, limits and error codes.

On this page▾
  • Before you start
  • Creating a flow
  • Reading the draft
  • Replacing the draft
  • Validating without saving
  • Validation errors
  • Advice
  • Limits
  • Errors
  • What's next

A flow's draft is the one version the API can write. You create it together with the flow, read it back to change it, replace it whole, and validate graphs against the same checks the dashboard applies when it saves. Publishing it stays with a person in the dashboard — see Flows. How a person builds the same draft in the dashboard is described in Building a flow.

Four endpoints, one shape: every draft travels as { "trigger": { ... } }, the graph nested inside the trigger. That shape is described node by node in Nodes, and the fastest way to get a correct one is a template payload.

Before you start

  1. 1

    Get a Product API token with automation write access

    Creating, replacing and validating need PROJECT_AUTOMATION_WRITE; reading the draft needs PROJECT_AUTOMATION_READ. Scopes are chosen when the token is minted, under Project settings → API tokens — see Authentication.

  2. 2

    Know your project UID

    Every call is scoped to one project, which owns the data sources, senders and segments the draft may reference.

  3. 3

    Export credentials

    export INSTASENT_PROJECT="proj_xxx"
    export INSTASENT_TOKEN="eyJhbGciOi..."
    export BASE="https://api.instasent.com/v1/project/$INSTASENT_PROJECT"

Creating a flow

POST/v1/project/{project}/flow

Create a flow together with its first draft.

namestring

The flow's name in the dashboard, up to 50 characters. Left out, the flow is named Untitled flow.

descriptionstring

An internal note about the flow.

tagsstring[]

Labels for organizing flows in the dashboard.

templatestring

The key of the template the flow is created from. Recorded once, at creation, and it marks the template as used. An unknown key is a 400. Sent without draft, the server builds the draft from the template; sent with one, the server completes your draft as described below.

draftobject

The graph, as { "trigger": { ... } }. See Nodes. Required unless you send template.

inputsobject

Only with template. The values the template asks for, input key to value. Without draft, a key left out keeps its default or stays pending; with a draft, each value replaces its $input:<key> in the draft. See Values the template asks for.

sendersobject

Only with template, with or without draft. { "sms": "<id>", "rcs": "<id>" }, both optional: the sender every send of that channel without one takes, instead of the project's pick. An id that is not an active sender of that channel in this project is a 422. See Choosing the senders.

channelstringdefault: sms

Only with template and no draft. sms or rcs: the mode the draft is built in.

langstringdefault: en

en or es: the language of the built draft's name and description. Read only with template and no draft, and ignored otherwise.

datasourceIdstring

Only with template and no draft. The source the trigger listens to, from those the template item accepts; left out, the server uses the recommended one. See The trigger's source.

With template and no draft, the draft is the one the template list shows as that item's payload, with your inputs filled in. With template and a draft, the draft stays yours and the server only completes it, never replacing a value you set: it substitutes your inputs, gives a sender to each send that has none, and gives the trigger the template's source when the draft leaves out the eventDatasource key (an explicit null is kept and listens to every source). The full walkthrough is in Creating a flow from a template.

curl -X POST "$BASE/flow" \
  -H "Authorization: Bearer $INSTASENT_TOKEN" \
  -H "Content-Type: application/json" \
  -d @flow.json

A successful call returns 201 Created:

{
  "entity": {
    "flowId": "66b1f2a4e5a6b7c8d9e0f1a2",
    "draftId": "66b1f2a4e5a6b7c8d9e0f1b7",
    "valid": false,
    "errors": [
      {
        "path": "graph",
        "message": "...",
        "parameters": { "errorsCount": 1, "uids": ["6f1c0a9e-..."] }
      }
    ],
    "nodeErrors": [
      {
        "uid": "6f1c0a9e-...",
        "stepClass": "ACTION_SEQUENTIAL_SEND",
        "errors": [
          { "path": "channel", "message": "The message still has a template value to fill in: discountCode" }
        ]
      }
    ],
    "warnings": [
      { "rule": "no-purchase-exit", "message": "..." }
    ],
    "filled": []
  }
}
flowIdstring

The new flow's id. The value every other flow endpoint takes, including the flow reports once it is published.

draftIdstring

The id of the draft just saved. Keep it: it is the expectedDraftId of your next replace.

validboolean

false means the draft cannot be published yet. errors says why.

errorsobject[]

The validation errors, each with path, message and parameters. Empty when valid is true. See Validation errors.

nodeErrorsobject[]

One entry per node that fails validation: its uid, its stepClass and errors, each with the node's path and a readable message. Empty when valid is true.

warningsobject[]

Advice on a graph that validates but probably misbehaves, each with rule and message. See Advice.

filledstring[]

The JSON path, from the draft root, of each sender and source the server set on a create with template, such as trigger.eventDatasource or trigger.nextStep.channel.options[0].sender. Empty when the server set nothing, and always empty without template. See Responses and errors.

An invalid draft is still saved, exactly as the dashboard saves one: the flow exists, and its draft carries valid: false and the reasons. On a flow made from a template, the usual gap is a pending input (a value such as a discount code the customer has not given yet) or a sender that could not be chosen because the project has several active senders, no default, and none was named in senders. Surface the errors to the person who will publish, or replace the draft once you have the missing values. Only a malformed request or a refused input or sender is turned down outright, not an invalid graph; see Errors.

Reading the draft

GET/v1/project/{project}/flow/{id}/draft

Read the flow's draft in the same shape it is written.

The response is the same flowId, draftId, valid, errors and nodeErrors, plus draft: the graph, with every node's uid kept so it can be edited and sent back whole. A flow with no draft answers 404.

A draft can change without you: a person may open the flow in the dashboard and save it, and every save produces a new draftId. Read before you replace.

Replacing the draft

PUT/v1/project/{project}/flow/{id}/draft

Replace the whole draft.

There is no partial edit. Every save — yours or a person's in the dashboard — replaces the whole draft and creates a new draft version with its own id. The request carries the graph and the id of the draft you started from:

expectedDraftIdstringrequired

The draftId you last read, or null when the flow has no draft. The field must be present even when it is null.

draftobjectrequired

The complete graph, as { "trigger": { ... } }.

If the flow's current draft is not the one you name, nothing is saved and the call answers 409 Conflict: someone saved in between, and overwriting their change silently would lose it. Read the draft again, reapply your change on top of it, and send it with the new draftId.

flowchart TD
    A[GET /flow/id/draft] --> B[Edit the graph, keep the uids]
    B --> C[PUT /flow/id/draft with expectedDraftId]
    C -->|200| D[Saved: keep the new draftId]
    C -->|409| A
    class D success

Keep the uid of every node you read. A node that keeps its uid keeps its identity across saves; omit it only on nodes you add.

A successful replace returns 200 OK with flowId, the new draftId, valid, errors and nodeErrors. Like creation, an invalid draft is saved. Editing the draft never changes what is live: the published version keeps running until a person publishes again.

Two things refuse a replace besides a stale draft: an archived flow, whose draft can no longer change (400), and a second save of the same flow within a couple of seconds of the previous one (429, retry after a moment).

Validating without saving

POST/v1/project/{project}/flow/{id}/draft/validate

Validate a graph against a flow without saving anything.

Send { "draft": { ... } } and get back valid, errors, nodeErrors and warnings, from the same checks a save runs. Nothing is stored, so it is the way to iterate on a graph before replacing a draft with it. The flow in the path must exist: create the flow first, then validate the changes you plan to make to it.

{
  "entity": {
    "valid": true,
    "errors": [],
    "nodeErrors": [],
    "warnings": [
      { "rule": "send-right-after-trigger", "message": "..." }
    ]
  }
}

Validation errors

Validation covers the graph's structure, each node's required settings, and limits on the flow as a whole. Each entry carries path, message and parameters. Base your handling on path and parameters: message is written for the dashboard and can still contain {{placeholders}} that parameters fills in.

  • Problems with the graph as a whole come as entries with path: "graph": a node reachable from more than one place, more than 50 nodes, waits on the longest path adding up to more than 180 days, or nodes that reference a sender or data source from outside this project (their uids are in parameters).
  • Problems inside nodes come as a single path: "graph" entry whose parameters carry errorsCount and the uids of the nodes in error, and the reasons come in nodeErrors: one entry per failing node, with its uid, its stepClass and each reason as a sentence. A node you add gets its uid when the draft is saved, so read the draft back to map a new node's errors.

The node problems you will meet most:

  • A send with no sender, or no text: The sms message is incomplete: it needs a sender and a text (or rcs). On a create with template, the server sets the senders when it can; it leaves one empty when the project has several active senders for that channel, none is the default and senders names none.
  • A pending input: The message still has a template value to fill in: <key>, once per value. The text still holds $input:<key> from a template, in the message, a translation, the fallback or an RCS button. Replace it with the value and save again.
  • A branch with the wrong paths: a missing path, a default path with a condition, the wrong number of fixed outcomes. See Nodes.
  • A value out of range: a delay shorter or longer than its node allows. See Delays and waits.

Advice

warnings flags a graph that validates but probably does not do what its author wants. It never blocks a save and is never stored; it rides the creation response and the validate response, not a replace.

ruleWhat it flags
send-right-after-triggerThe first step is a send. Put a smart delay first, unless the message confirms what the contact just did.
no-purchase-exitA checkout or product journey with no exit on ecommerce_order_create, so a buyer keeps getting reminders.
too-many-sendsOne path sends more than 3 messages.
fixed-delay-before-sendA fixed delay directly before a marketing send, which can land at any hour of the night.
no-compliance-policyA send with no consent policy. See The send.

Read every entry: each one describes a journey that will misbehave in front of contacts once it is published.

Limits

LimitValue
Flows never published, per project50
Nodes in a graph50
Total waits on the longest path180 days
nameup to 50 characters

The first limit exists so an automated caller cannot fill a project with drafts in a loop; it is checked before any other work, and only on creation. A flow counts towards it until it is published, and stops counting once a person publishes or archives it.

Errors

StatusWhenWhat to do
400The body is not a JSON object; draft is missing (with no template) or has no trigger; the draft uses a node type the API does not accept (the message lists the allowed ones); template is unknown; on a create from a template: inputs or senders is not an object, channel is not a string or not a mode the project offers, inputs, senders, channel or datasourceId come without a template, channel or datasourceId come with a draft, or datasourceId is empty or not one the template accepts; expectedDraftId is absent; the flow is archived.Fix the request. Retrying unchanged fails the same way.
403The token lacks the scope, or the organization owner is not verified (code: "organization.verification_required").See Errors.
404The flow does not exist in this project, or has no draft to read.Check the id.
409On replace: the draft changed since you read it. On create: the project is at its limit of never-published flows.See below.
422A value in the draft has the wrong shape, or it references a sender, data source or segment that does not exist in this project. On a create from a template: an input the template does not declare, or a value its kind refuses; or a senders id that is not an active sender of that channel in this project.Read errors.fields: draft names the value and the expected shape; inputs.<key> names the input and the reason; senders.<channel> names the refused sender. Nothing is created.
429The rate limit, or a second save of the same flow within a couple of seconds.Back off and retry.

The two 409s are told apart by their body. The draft limit is the only one with a machine-readable code at the top level:

{
  "code": "flow-draft-limit-reached",
  "message": "This project already has 50 flows that were never published, the most allowed. Publish or delete one before creating another; retrying will fail the same way.",
  "limit": 50,
  "count": 50
}

Retrying it changes nothing until a flow is published or archived in the dashboard, so report it rather than looping. The dashboard has no delete action for flows: where the message says delete, archiving is what frees the slot. The stale-draft 409 carries only a message; its remedy is always to read the draft again.

A 422 looks like the other field errors of the Product API:

{
  "errors": {
    "fields": {
      "draft": ["A value in the draft has the wrong shape: ..."]
    }
  }
}

The most common cause is an RCS message written as a bare string: an RCS text is { "text": { "text": "..." } }. A missing input value is never a 422: the flow is created and the send reports the pending input. Everything else (401, 5xx) behaves as described in Errors.

What's next

Nodes

The graph you send as draft, node by node.

Triggers and exits

The trigger event and its source, re-entry, exits and goals.

Delays and waits

How each kind of wait is configured, and what counts towards the 180 days.

Last updated November 12, 2026

PreviousTemplatesNextTriggers and exits
  • Before you start
  • Creating a flow
  • Reading the draft
  • Replacing the draft
  • Validating without saving
  • Validation errors
  • Advice
  • Limits
  • Errors
  • What's next

© 2026 Instasent

Privacy PolicyTerms & ConditionsCookie PolicyLegal Notice
All systems operational