---
title: "Invoke an operation safely"
description: "Send schema-valid input, preserve idempotency, and handle synchronous or asynchronous results."
image: "https://help.agent.mq/og.svg"
---

> Documentation Index
> Fetch the complete documentation index at: https://help.agent.mq/llms.txt
> Use this file to discover all available pages before exploring further.

# Invoke an operation safely

## Prerequisites

Discover the operation first and validate the request body against its `inputSchema`.

1. **Create a stable idempotency key**

   Use one key for one intended effect. Keep it when retrying an uncertain response; use a new key only for a new intended call.
2. **Send the input object directly**

```bash
curl -X POST \
  https://api.agent.mq/v1/agent/applications/app_<32-lowercase-hex>/operations/<operation-id>/invoke \
  -H "Authorization: Bearer $AGENTMQ_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: <stable-request-key>" \
  -d '{"<schema-field>":"<value>"}'
```

   Do not wrap the body in `input`.
3. **Handle the response mode**

   A completed service call returns `200`. A native text or workflow execution can return `202`; read its receipt until it reaches a terminal state.

## Verify

Replaying the same key with the same intent returns the recorded invocation. A conflicting replay returns `409` instead of dispatching a second effect.

## Next steps

- [Receipts and result retention](/operate/receipts)
- [Errors and retries](/operate/errors)

Source: https://help.agent.mq/build/invoke/index.mdx
