Tutorial: a complete connector
This tutorial builds a connector for Acme Tasks, a fictional task-management API, from an empty file to a tested connector with:
- two authentication alternatives (API key and OAuth2),
- create, get, update, delete and list operations, with cursor pagination,
- a dropdown of projects and a dependent dropdown of sections,
- a three-step file upload,
- a polling trigger for new tasks,
- a webhook trigger that registers itself with the service and verifies signatures,
- cassette tests for all of it.
Acme Tasks does not exist; its API is described inline so the example is self-contained. With a
real service, every fact below would come from the vendor’s API reference, and its URLs would go
into provenance:.
The API we are wrapping
| Endpoint | Behavior |
|---|---|
GET /v2/me | Returns the authenticated user. Good for credential tests. |
GET /v2/projects?limit=&cursor= | { "data": [...], "next_cursor": "..." }, cursor is absent on the last page |
GET /v2/projects/{id}/sections | { "data": [ { "id", "name" } ] } |
POST /v2/projects/{id}/tasks | Creates a task, returns { "task": {...} } |
GET /v2/tasks/{id} | { "task": {...} } |
PATCH /v2/tasks/{id} | Partial update, returns { "task": {...} } |
DELETE /v2/tasks/{id} | 204 No Content |
GET /v2/projects/{id}/tasks?limit=&cursor=&created_after= | Paginated like projects |
POST /v2/tasks/{id}/uploads | { "upload_id", "upload_url" } for a file of a given name, size and type |
PUT <upload_url> | Raw file bytes, no auth header (the URL is pre-signed) |
POST /v2/tasks/{id}/attachments | { "upload_id" }, returns { "attachment": {...} } |
POST /v2/webhooks, GET/DELETE /v2/webhooks/{id} | Webhook registrations; creation returns { "id", "secret" } |
Errors look like { "error": { "code": "not_found", "message": "Task t_1 does not exist" } }.
Webhook deliveries carry X-Acme-Signature: sha256=<hex HMAC-SHA256 of the raw body> and the
service sends { "type": "ping" } once when a webhook is created, expecting 200.
1. Header, base URL and defaults
tappet connector new acme_tasks
id: acme_tasks
format_version: 1
display_name: Acme Tasks
description: Create and track tasks and projects in Acme Tasks.
category: [productivity]
icon: lucide:list-checks
docs_url: https://developer.acme-tasks.example.com
provenance:
- https://developer.acme-tasks.example.com/reference
- https://developer.acme-tasks.example.com/auth
- https://developer.acme-tasks.example.com/webhooks
base_url: https://api.acme-tasks.example.com/v2
defaults:
headers: { Accept: application/json }
rate_limit: { strategy: retry_after, max_retries: 5, rps: 10 }
errors:
message: "{{ response.body.error.message }}"
vendor_code: "{{ response.body.error.code }}"
base_urlis prepended to everypath:. Absoluteurl:values bypass it.rate_limitretries429and5xxup to five times, honoringRetry-After, and limits each credential to 10 requests per second.errors.messageturns the vendor’s error body into the node error message;vendor_codeis kept as a separate field so workflows can branch on it.
2. Authentication
auth:
- id: api_key
kind: api_key
display_name: API key
in: header
name: Authorization
prefix: "Token "
fields:
- { name: api_key, display_name: API key, secret: true, required: true,
description: Create one under Settings > Developer in Acme Tasks. }
test:
request: { method: GET, path: /me }
- id: oauth2
kind: oauth2_auth_code
display_name: OAuth2
authorize_url: https://acme-tasks.example.com/oauth/authorize
token_url: https://api.acme-tasks.example.com/oauth/token
scopes: [tasks.read, tasks.write, webhooks]
scope_separator: " "
pkce: true
client_auth: body
test:
request: { method: GET, path: /me }
The first alternative is the default. Users choose between them when they create a credential.
oauth2_auth_code needs no fields:: client ID and client secret are the standard fields, and the
access and refresh tokens are managed by the vault, including refresh before expiry. Credential
kinds are named <connector>/<auth id>, here acme_tasks/api_key and acme_tasks/oauth2. See
Authentication for all kinds.
3. A first operation
resources:
task:
display_name: Task
operations:
create:
display_name: Create a task
description: Adds a task to a project, optionally in a section and with a due date.
side_effect: true
params:
- { name: project, type: resource_locator, lookup: projects, required: true }
- { name: title, type: string, required: true }
- { name: section, type: options, lookup: sections, depends_on: [project] }
- name: additional_fields
type: collection
fields:
- { name: notes, type: string }
- { name: due_on, type: datetime }
- { name: priority, type: options, options: [low, normal, high], default: normal }
request:
method: POST
path: "/projects/{{ params.project | urlencode }}/tasks"
body:
encoder: json
omit_empty: true
fields:
title: "{{ params.title }}"
section_id: "{{ params.section }}"
notes: "{{ params.additional_fields.notes }}"
due_on: "{{ params.additional_fields.due_on }}"
priority: "{{ params.additional_fields.priority }}"
output: { select: "$.task", split: false }
Things to notice:
- Parameters are resolved by the workflow engine before the connector runs, so
params.titleis already a plain value even if the user wrote an expression. - A template that is exactly one
{{ }}keeps its type:prioritystays a string, a numeric parameter would stay a number. omit_empty: truedrops fields whose value is null or empty, so optional fields that the user left blank are not sent.urlencodeprotects the path from IDs with special characters.output.selectpicks the task out of the response envelope.split: falsekeeps it as one item.
The operation runs once per input item (per_item: true is the default), so ten input items
create ten tasks.
4. The rest of the CRUD operations
get:
display_name: Get a task
params:
- { name: task_id, type: string, required: true }
request: { method: GET, path: "/tasks/{{ params.task_id | urlencode }}" }
output: { select: "$.task", split: false }
update:
display_name: Update a task
side_effect: true
params:
- { name: task_id, type: string, required: true }
- name: update_fields
type: collection
fields:
- { name: title, type: string }
- { name: notes, type: string }
- { name: completed, type: boolean }
request:
method: PATCH
path: "/tasks/{{ params.task_id | urlencode }}"
body:
encoder: json
omit_empty: true
value: "{{ params.update_fields }}"
output: { select: "$.task", split: false }
delete:
display_name: Delete a task
side_effect: true
params:
- { name: task_id, type: string, required: true }
request: { method: DELETE, path: "/tasks/{{ params.task_id | urlencode }}" }
output: { value: { deleted: true, id: "{{ params.task_id }}" }, split: false }
list:
display_name: List tasks in a project
params:
- { name: project, type: resource_locator, lookup: projects, required: true }
- { name: return_all, type: boolean, default: false }
- { name: limit, type: number, default: 50 }
request:
method: GET
path: "/projects/{{ params.project | urlencode }}/tasks"
query: { limit: 100 }
paginate:
strategy: cursor
cursor_from: "$.next_cursor"
cursor_param: cursor
items: "$.data"
body.valuesends a whole object (the update collection) instead of listingfields.deletereturns no body, sooutput.valuebuilds the output item from parameters.listdeclarespaginate. Withreturn_all: truethe runtime followsnext_cursoruntil it is missing; otherwise it stops afterlimititems. Each element of$.databecomes one output item. The safety cap is 100 pages unless the operation setsmax_pages.
5. Lookups and resource locators
The project parameter is a resource locator: users pick from a list, paste an ID, or paste a
URL. The section dropdown depends on the chosen project.
lookups:
projects:
request: { method: GET, path: /projects, query: { limit: 100 } }
paginate: { strategy: cursor, cursor_from: "$.next_cursor", cursor_param: cursor }
items: "$.data"
label: "{{ item.name }}"
value: "{{ item.id }}"
url: "https://acme-tasks.example.com/p/{{ item.id }}"
search: client
sections:
depends_on: [project]
request: { method: GET, path: "/projects/{{ params.project | urlencode }}/sections" }
items: "$.data"
label: "{{ item.name }}"
value: "{{ item.id }}"
url_patterns:
project: "acme-tasks\\.example\\.com/p/(?<id>[^/?#]+)"
Lookups run through the same HTTP client, credentials and egress policy as operations, and their
results are cached for 60 seconds per credential and parameters. url_patterns turns a pasted URL
into an ID: the named group id is the value. See Pagination and lookups.
6. A multi-step upload
Attaching a file takes three requests. Each step’s response is available to later steps as
steps.<id>.
attachment:
display_name: Attachment
operations:
upload:
display_name: Attach a file to a task
side_effect: true
params:
- { name: task_id, type: string, required: true }
- { name: binary_property, type: binary_property, default: data }
steps:
- id: start
request:
method: POST
path: "/tasks/{{ params.task_id | urlencode }}/uploads"
body:
encoder: json
fields:
file_name: "{{ binary[params.binary_property].file_name }}"
size: "{{ binary[params.binary_property].file_size }}"
content_type: "{{ binary[params.binary_property].mime_type }}"
- id: put
request:
method: PUT
url: "{{ steps.start.body.upload_url }}"
auth: none
body: { encoder: raw_binary, binary_property: "{{ params.binary_property }}" }
- id: finish
request:
method: POST
path: "/tasks/{{ params.task_id | urlencode }}/attachments"
body: { encoder: json, fields: { upload_id: "{{ steps.start.body.upload_id }}" } }
output: { from_step: finish, select: "$.attachment", split: false }
binary.<property>exposes the input item’s file metadata (file_name,mime_type,file_size).auth: noneon theputstep prevents the API key from being sent to the storage host.raw_binarystreams the file from the blob store; large files are never loaded into memory.
More patterns, including for_each fan-out and resumable uploads, are in
Multi-step operations and uploads.
7. A polling trigger
triggers:
new_task:
kind: poll
display_name: New task
description: Starts the workflow for each task created in a project.
params:
- { name: project, type: resource_locator, lookup: projects, required: true }
request:
method: GET
path: "/projects/{{ params.project | urlencode }}/tasks"
query:
limit: 100
created_after: "{{ trigger.cursor or trigger.now }}"
paginate: { strategy: cursor, cursor_from: "$.next_cursor", cursor_param: cursor, items: "$.data" }
dedupe_key: "{{ item.id }}"
cursor: "{{ items | map(attribute='created_at') | max if items else (previous or trigger.now) }}"
How it behaves:
- The poll interval comes from the node’s poll-times setting in the workflow.
- On the first poll after activation nothing is emitted (unless
emit_on_first_poll: true); the trigger only records its starting point. - Each later poll asks for tasks created after the stored cursor, skips any task whose
dedupe_keyit has already emitted, and stores the newestcreated_atas the next cursor. When a poll finds nothing, the template keeps the previous cursor (or, on the very first poll, the current time), so no task created between polls is missed. - The cursor and the seen keys live in the workflow’s static data, so they survive restarts.
8. A webhook trigger
task_event:
kind: webhook
display_name: Task event
description: Starts the workflow when tasks are created, updated or completed.
params:
- { name: project, type: resource_locator, lookup: projects, required: true }
- name: events
type: multi_options
required: true
options: [task.created, task.updated, task.completed]
lifecycle:
check:
request: { method: GET, path: "/webhooks/{{ static.hook_id }}" }
exists_when: "{{ response.status == 200 }}"
create:
request:
method: POST
path: /webhooks
body:
encoder: json
fields:
url: "{{ webhook_url }}"
project_id: "{{ params.project }}"
events: "{{ params.events }}"
store:
hook_id: "{{ response.body.id }}"
signing_secret: "{{ response.body.secret }}"
delete:
request: { method: DELETE, path: "/webhooks/{{ static.hook_id }}" }
verify:
scheme: hmac_sha256
header: X-Acme-Signature
prefix: "sha256="
secret: "{{ static.signing_secret }}"
respond:
- when: "{{ request.body.type == 'ping' }}"
status: 200
body: { ok: true }
filter: "{{ request.body.type in params.events }}"
output: { select: "$.task", split: false }
- On activation,
checklooks for an existing registration (when static data has one), andcreateregisterswebhook_urlwith the service and stores the returned ID and signing secret in static data.TAPPET_PUBLIC_URLmust be set forwebhook_urlto exist. - On deactivation,
deleteremoves the registration.404and410count as already removed. - Each delivery is processed in this order:
respondrules are checked first, so handshakes (here, the ping) are answered without starting the workflow. Keep them narrow: they run before signature verification, because some services send their handshake before a secret exists.- The signature in
X-Acme-Signatureis verified with a constant-time comparison. A missing or wrong signature is answered with401and never starts the workflow. filteracknowledges (with200) events the user did not select, without starting the workflow.outputshapes the body into items, and the workflow starts.
9. Tests
Each file in tests/ is one scenario. Outbound requests must match exchanges in order; the
canned responses are served back; the node output is compared with expect.
tests/task_create.cassette.yaml:
name: create a task with optional fields omitted
operation: task.create
auth: api_key
credential: { api_key: test-key }
params:
project: p_1
title: Write docs
additional_fields: { priority: high }
exchanges:
- request:
method: POST
url: https://api.acme-tasks.example.com/v2/projects/p_1/tasks
headers: { authorization: "Token test-key" }
body_json: { title: Write docs, priority: high }
response:
status: 201
body_json: { task: { id: t_901, title: Write docs, priority: high } }
expect:
output: [ { id: t_901, title: Write docs, priority: high } ]
tests/task_list_paginated.cassette.yaml:
name: list follows the cursor until it is absent
operation: task.list
auth: api_key
credential: { api_key: test-key }
params: { project: p_1, return_all: true }
exchanges:
- request: { method: GET, url: "https://api.acme-tasks.example.com/v2/projects/p_1/tasks?limit=100" }
response: { body_json: { data: [ { id: t_1 }, { id: t_2 } ], next_cursor: c2 } }
- request: { method: GET, url: "https://api.acme-tasks.example.com/v2/projects/p_1/tasks?limit=100&cursor=c2" }
response: { body_json: { data: [ { id: t_3 } ] } }
expect:
output: [ { id: t_1 }, { id: t_2 }, { id: t_3 } ]
tests/task_get_not_found.cassette.yaml:
name: missing task surfaces the vendor message
operation: task.get
auth: api_key
credential: { api_key: test-key }
params: { task_id: t_404 }
exchanges:
- request: { method: GET, url: https://api.acme-tasks.example.com/v2/tasks/t_404 }
response:
status: 404
body_json: { error: { code: not_found, message: Task t_404 does not exist } }
expect:
error: { contains: Task t_404 does not exist }
tests/lookup_projects.cassette.yaml:
name: projects lookup returns label and value
operation: lookup:projects
auth: api_key
credential: { api_key: test-key }
exchanges:
- request: { method: GET, url: "https://api.acme-tasks.example.com/v2/projects?limit=100" }
response: { body_json: { data: [ { id: p_1, name: Website }, { id: p_2, name: Mobile } ] } }
expect:
output:
- { label: Website, value: p_1, url: "https://acme-tasks.example.com/p/p_1" }
- { label: Mobile, value: p_2, url: "https://acme-tasks.example.com/p/p_2" }
tests/attachment_upload.cassette.yaml:
name: upload runs three steps and sends no auth to the storage host
operation: attachment.upload
auth: api_key
credential: { api_key: test-key }
params: { task_id: t_901, binary_property: data }
input:
- json: {}
binary:
data: { file_name: notes.txt, mime_type: text/plain, text: "hello" }
exchanges:
- request:
method: POST
url: https://api.acme-tasks.example.com/v2/tasks/t_901/uploads
body_json: { file_name: notes.txt, size: 5, content_type: text/plain }
response:
body_json: { upload_id: u_1, upload_url: "https://uploads.acme-tasks.example.com/u_1?sig=abc" }
- request:
method: PUT
url: "https://uploads.acme-tasks.example.com/u_1?sig=abc"
absent_headers: [authorization]
body_text: hello
response: { status: 200 }
- request:
method: POST
url: https://api.acme-tasks.example.com/v2/tasks/t_901/attachments
body_json: { upload_id: u_1 }
response:
body_json: { attachment: { id: a_1, file_name: notes.txt } }
expect:
output: [ { id: a_1, file_name: notes.txt } ]
tests/trigger_task_event_activate.cassette.yaml and tests/trigger_task_event.cassette.yaml:
name: activation registers the webhook and keeps its id and secret
operation: trigger:task_event:activate
auth: api_key
credential: { api_key: test-key }
params: { project: p_1, events: [task.created] }
exchanges:
- request:
method: POST
url: https://api.acme-tasks.example.com/v2/webhooks
body_json: { url: https://tappet.test/webhook/hook-1, project_id: p_1, events: [task.created] }
response:
status: 201
body_json: { id: wh_7, secret: whsec_test }
expect:
static_data: { hook_id: wh_7, signing_secret: whsec_test }
name: signed delivery starts the workflow with the task
operation: trigger:task_event
auth: api_key
credential: { api_key: test-key }
params: { project: p_1, events: [task.created] }
static_data: { hook_id: wh_7, signing_secret: whsec_test }
webhook:
method: POST
headers:
content-type: application/json
X-Acme-Signature: sha256=cb6d5a68bac250d2f9ba40921fbe706a7ef490a20ceae502bb55959c50948258
body: '{"type":"task.created","task":{"id":"t_901","title":"Write docs","project_id":"p_1"}}'
expect:
output: [ { id: t_901, title: Write docs, project_id: p_1 } ]
Run them:
tappet connector lint acme_tasks
tappet connector test acme_tasks
A failing cassette lists every mismatch: requests that were expected but not made, unexpected requests, request fields that differ, and output items that do not match. See Cassette tests for the full format.
The complete connector from this tutorial, with these cassettes and eight more (update, delete,
the limit stop, the sections lookup, a poll that advances its cursor, a rejected signature, the
ping handshake and deactivation), is in
docs/connectors/examples/acme_tasks/.
docs/tools/check_docs.py verifies that every snippet on this page matches those files, and the
cassettes pass against the connector runtime.
10. Try it
TAPPET_CONNECTORS_DIR=./connectors tappet serve
Your working copy now overrides the embedded catalog. Create an Acme Tasks credential, add the node to a workflow, and run each operation once against the real service.
Where to go from here
- File format reference for every key used above and the template language.
- Native hooks when an operation cannot be expressed in YAML.
- Mapping files if the service has an n8n node whose workflows should import onto this connector.