Elixir client
Our Elixir package is a lightweight, Req-based client that includes component modules, pagination, structured errors, and webhook verification.
Create a Req client
client =
Incld.client(System.fetch_env!("INCLD_SECRET_KEY"),
base_url: "https://api.incld.dev/v1",
organization_id: organization_id,
user_id: user_id # omit for organization-wide server work
)
Every function returns
{:ok, value}
or {:error, exception}. Single-resource functions unwrap data; list functions return a map with
data
and meta.has_more/next_cursor.
The unscoped client is a project administrator
organization_id:. Add
user_id:
when acting as one end user. The client rejects user scope without an organization.
Module functions
| Module | Functions |
|---|---|
| Incld.Actions | define/2, list/2, get/2 |
| Incld.Schedules | list/2, get/2, create/3, update/3, delete/2, pause/2, resume/2, list_runs/3, events/3, preview/3 |
| Incld.Runs | list/2, get/2 |
| Incld.Approvals | list/2, get/2, check/5, create/3, update/3, decide/5, approve/4, reject/4, cancel/4, revoke/4, delete/2, events/2 |
| Approval policies | list_policies/1, get_policy/2, create_policy/2, update_policy/3, delete_policy/2 |
| Incld.Audit | list/2, get/2, create/3 |
| Incld.Bulk | list/2, get/2, create/3, chunks/2, events/2, cancel/3 |
| Incld.Sessions | create/2 |
| Incld.Webhook | verify/3 and verify/4 |
Create and page resources
{:ok, schedule} =
Incld.Schedules.create(client, %{
action: "generate_report",
recurrence: %{
frequency: "daily",
interval: 1,
local_time: "09:00",
timezone: "Australia/Melbourne"
},
timezone: "Australia/Melbourne"
}, idempotency_key: "report:org_123:user_123")
{:ok, %{data: schedules, meta: meta}} =
Incld.Schedules.list(client, %{
limit: 100,
cursor: nil
})
Structured errors
case Incld.Approvals.get(client, approval_id) do
{:ok, approval} -> approval
{:error, %Incld.APIError{} = error} ->
Logger.error("incld request failed",
status: error.status,
code: error.code,
fields: error.fields,
request_id: error.request_id
)
end
Verify webhooks
with [signature] <- get_req_header(conn, "incld-signature"),
{:ok, event} <- Incld.Webhook.verify(raw_body, signature, secret) do
dispatch(event)
end
The verifier parses the timestamped t=...,v1=...
signature, enforces a 300-second default tolerance, performs a constant-time comparison, and returns the decoded JSON event.