Skip to main content
Workflows are routines that can be conducted by agents in Monumint. You can use the API to start workflows on your leads. An agent conducts one workflow at a time on a given lead, so over the lifetime of a lead an agent works through a sequence of them, one after another. This guide walks the full experience: create a lead, determine which agent and workflow you want to run, kick off the workflow on that lead, then hand the agent its next job once that one finishes. Four resources appear in this guide:

Before you start

  1. Generate an API key. Visit workspace settings to create an API key.
  2. Configure agents and workflows in the app. Visit agent settings to add and configure agents, and visit workflow settings to add and configure workflows.
All requests should be made to https://api-v2.getomni.ai. Use your workspace API key to authenticate with the x-api-key header.

1. Create a lead

If you already create leads through the API or a CRM sync, you can reuse existing leads and skip to step 2. To create a lead through the API: POST /api/v1/leads

2. Identify your agents and workflows

Agents and workflows can be configured within the Monumint app. Once they are set up, you can retrieve ids that identify each workflow and agent. To retrieve the agents configured in your workspace: GET /api/v1/agents
To retrieve the workflows configured in your workspace: GET /api/v1/workflows
Each workflow has a type that defines what work actually gets performed:

3. Create the workflow run

Up until this point, we’ve configured agents and workflows, and we’ve created leads in Monumint, but no work is actually being performed. To tell an agent to start conducting a workflow on a particular lead, we need to create a workflow run: POST /api/v1/workflow-runs
Depending on the workflow’s type, the agent may begin to send messages to the lead over text, email, and other channels. At this point, you should store workflowRun.id for use with the additional endpoints and webhooks described below.

4. Subscribe to events

Monumint dispatches webhook events so that you can stay informed of activity tied to a workflow run. You can register to receive workflow run events with Create Webhook: POST /api/v1/webhooks
The events which pertain to workflow runs are: Each event carries the workflow run under workflowRun — the same object the endpoints above return — alongside the workspace, the lead, and your own externalLeadId:
Event payload
See Webhook Events for a complete reference of every event and its payload.

5. Create another workflow run

An agent generally conducts one workflow at a time on a given lead. But once that workflow finishes, you can tell the agent to perform another job on that lead by calling the workflow run creation endpoint again, usually with a different workflow id: POST /api/v1/workflow-runs
If you create a workflow run while the agent is still conducting one on the same lead, the request is rejected with 409 Agent is already linked to this lead. Wait for the agent to finish, or cancel the current workflow run first.

6. Manage the workflow run

Once a workflow run exists, you may wish to control it through various operations. Each is a POST with no body, and returns the workflow run in its new state. Each of these acts on a single workflow run rather than on the agent or the lead. Cancelling one frees the agent to take on its next job for that lead.

7. Monitor workflow runs

In addition to staying apprised of workflow run activity using the events described above, you can also use the following endpoints to check the current state of workflow runs. To read one workflow run: GET /api/v1/workflow-runs/{workflowRunId}
Or to list all workflow runs for a lead: GET /api/v1/workflow-runs?leadId={leadId}
Workflow runs are returned newest first, so this is the lead’s work history: what the agent is conducting now, and everything it has already finished.

8. Wrapping up with a lead

In the lifespan of a lead, you may ask your agents to perform multiple workflows. A lead can remain active in your system even if no work is actively being conducted on it. For leads that you consider fully complete, you can mark the lead as completed to wrap up their entire record: PUT /api/v1/leads

9. Putting it all together

The script below wires the whole guide together: it creates a lead, looks up the agent and workflow to use, subscribes to the events, puts the agent to work, and reads the result back. It uses jq to pull ids out of each response.