Each invocation has its own unique ID and lifecycle.
Have a look at managing invocations to learn how to manage the lifecycle of an invocation.
/restate/ path prefix.
To invoke a handler, use /restate/call/... to wait for the response or /restate/send/... to send a message without waiting:
{key} segment for Virtual Objects and Workflows; omit it for basic Services.
The unversioned paths (
/{service}/{handler}, /{service}/{key}/{handler}, and the /send suffix) still work for backwards compatibility, but new code should use the /restate/ paths documented here.Request-response calls
You can invoke services over HTTP 1.1 or higher. Request/response bodies should be encoded as JSON. InvokemyHandler of MyService as follows:
myHandler of MyVirtualObject for myObjectKey as follows:
run handler of the MyWorkflow as follows:
x-restate-id.
Follow the same pattern for calling the other handlers of the workflow.
Note that all invocations go first via the Restate Server. The server then forwards the request to the appropriate service.
Therefore,
localhost:8080 refers to ingress port of the Restate Server, not the service instance.Sending messages
If you do not want to wait for the response, you can send a message by using/restate/send/... instead of /restate/call/...:
Delayed messages
You can delay the message by adding a delay request parameter in ISO8601 notation or using humantime format:You cannot yet use this feature for workflows.
Workflows can only be scheduled with a delay from within another Restate handler (TS/Java/Kotlin).
Using an idempotency key
You can send requests to Restate providing an idempotency key, through theIdempotency-Key header:
When the
controlled-idempotent-sharding cluster feature is enabled (the default for new clusters), the ingress assigns a random idempotency key to service and virtual object calls that don’t send an Idempotency-Key header.
This lets the ingress safely retry in-flight requests without duplicate execution, and means the completed invocation is retained for the idempotency retention period.
It does not deduplicate across different requests, since each call gets a distinct key.Scopes
Scopes are part of the flow control feature.
Scoped invocations are rejected unless the server is started with the experimental
vqueues feature enabled (experimental-enable-vqueues = true).scope/{scopeKey} segment in front of the call or send verb:
MyService/myHandler within the scope tenant-a:
See flow control to learn how to configure concurrency limits for a scope.
Cancel
You can cancel an invocation as follows:curl
Attach to an invocation
Restate allows you to retrieve the result of workflows and invocations that used an idempotency key. There are two options:- To attach to an invocation or workflow and wait for it to finish, use
attach. - To peek at the output of an invocation or workflow, use
output. This will return:{"message":"not ready"}for ongoing invocations- The result for finished invocations
{"message":"not found"}for non-existing invocations
By invocation ID
If you already have the invocation ID, attach to it or read its output with aGET request:
By target
If you don’t have the invocation ID, send aPOST request to /restate/attach or /restate/output with a JSON body describing the workflow or idempotency target. You can also address an invocation by its ID through the same body shape, as an alternative to the GET form above:
/restate/output to peek at the result.
If the target was invoked within a scope, add the optional "scope" field to the body.
Looking up the invocation ID
To resolve a workflow or idempotency target into its invocation ID, send aPOST request to /restate/lookup with the same body shape as above:
GET attach and output endpoints:
OpenAPI support
Restate exposes for every service an OpenAPI 3.1 definition, to get it:- TypeScript SDK with Zod schemas
- Python SDK with Pydantic models
- Java and Kotlin SDK