Lemline documentation Help

How to make an HTTP call

Set call: http and configure the HTTP method and endpoint under with.

The examples call the tutorial shop. Complete the SQLite setup and keep its worker running. Start the shop from the root of the Lemline source checkout, then run the other commands from a second terminal in the setup directory. With the JAR, substitute java -jar lemline.jar for bin/lemline.

docker compose -f examples/tutorial-services/compose.yaml up -d

Save this definition as check-stock.yaml:

document: dsl: '1.0.3' namespace: examples name: check-stock version: '0.1.0' title: Check the shop stock do: - getStock: call: http with: method: get endpoint: http://127.0.0.1:8787/stock
bin/lemline definition post -f check-stock.yaml bin/lemline instance start examples check-stock

The response body becomes the task output: {"sku":"SKU-1","available":100,"reserved":0}.

Build the request

Use headers and query for request headers and query parameters. For a POST or PUT request, supply body as a value or a workflow expression. See the HTTP Task Reference for request options and output modes.

Use a dynamic endpoint

Use a jq expression for the complete endpoint when it depends on task input. Escape an input value before inserting it into the URL path.

document: dsl: '1.0.3' namespace: examples name: dynamic-http-endpoint version: '1.0.0' do: - getProduct: call: http with: method: get endpoint: '${ "http://127.0.0.1:8787/products/\(.productId | @uri)" }'

Save it as dynamic-http-endpoint.yaml and read one known and one unknown product:

bin/lemline definition post -f dynamic-http-endpoint.yaml bin/lemline instance start examples dynamic-http-endpoint --input '{"productId":"SKU-2"}' bin/lemline instance start examples dynamic-http-endpoint --input '{"productId":"SKU 404"}'

The first instance returns the watering can, {"id":"SKU-2","name":"Watering can","category":"garden","price":12,"available":10}. For the second, @uri sends /products/SKU%20404; the shop answers HTTP 404 and the workflow faults with a communication error, status 404, whose title starts with HTTP 404. Write path templates such as {productId} as an expression like this one: Lemline does not expand URI templates.

Authenticate

Use a service-specific header or query parameter for an API key. Use an endpoint authentication policy for basic or bearer authentication.

Recover from an HTTP error

Wrap the call in a try task, select the errors to handle in catch, and add a retry policy or a fallback list where appropriate. A failed HTTP call raises a communication error whose status is the HTTP status and whose title is HTTP <code>: <body>. Match it with catch.errors.with, as here.

document: dsl: '1.0.3' namespace: examples name: retry-and-fallback version: '1.0.0' use: retries: transient: delay: PT2S backoff: exponential: {} limit: attempt: count: 3 do: - fetchInventory: try: - requestInventory: call: http with: method: get endpoint: http://127.0.0.1:8787/stock query: fail: '503' failTimes: ${ .failures // 0 | tostring } key: ${ $workflow.id } catch: errors: with: type: https://open-workflow-specification.org/spec/1.0.0/errors/communication status: 503 retry: transient do: - useCachedInventory: set: inventory: [] stale: true

The failures input makes the shop answer HTTP 503 that many times. Save the definition as retry-and-fallback.yaml:

bin/lemline definition post -f retry-and-fallback.yaml bin/lemline instance start examples retry-and-fallback --input '{"failures":1}' bin/lemline instance start examples retry-and-fallback --input '{"failures":5}'

The first instance returns the stock after one retry. The second fails four times, then returns {"inventory":[],"stale":true}. Allow about a minute: the worker picks up delayed retries every 10 seconds. Stop the shop when you are done:

docker compose -f examples/tutorial-services/compose.yaml down

Run the checkout workflow to see request bodies, HTTP failure handling and idempotent release against a local service.

25 November 2026