# Delay an HTTP request

Source: https://stormedo.com/docs/how-to/delay-requests/

Send once after a duration or at an absolute time, inspect the scheduled delivery, and cancel it before it runs.

Use `delay` for one future delivery relative to submission, or `deliver_at` for a particular instant. Use a [recurring schedule](https://stormedo.com/docs/how-to/schedule-requests/) for repeated work.

## Deliver after five minutes

Use a project API key from the [quickstart](https://stormedo.com/docs/get-started/first-request/). This example sends to Stormedo’s test destination:

```bash
curl --request POST \
  'https://api.stormedo.com/send?url=https://api.stormedo.com/ping&delay=5m&retry=3' \
  --header "Authorization: Bearer $STORMEDO_TOKEN" \
  --header 'Idempotency-Key: delayed-ping-001' \
  --header 'Content-Type: application/json' \
  --data '{"message":"Five minutes later"}'
```

The `202` response has `status: "scheduled"` and an absolute `scheduled_at`. Record its `data.id`. Reuse this key only when recovering this same submission; use a new logical key for a different test.

## Deliver at an absolute time

Generate a future time instead of copying a timestamp that will expire. JavaScript uses a `Date`:

```ts
const request = await stormedo.send("https://api.stormedo.com/ping", {
  body: { message: "At a chosen time" },
  deliverAt: new Date(Date.now() + 10 * 60 * 1000),
  maxAttempts: 4,
  idempotencyKey: "timed-ping-001",
});
```

Python uses a timezone-aware `datetime`:

```python
from datetime import datetime, timedelta, timezone

request = stormedo.send(
    "https://api.stormedo.com/ping",
    body={"message": "At a chosen time"},
    deliver_at=datetime.now(timezone.utc) + timedelta(minutes=10),
    max_attempts=4,
    idempotency_key="timed-ping-001",
)
```

These SDK snippets use a `stormedo` client initialized in the [JavaScript](https://stormedo.com/docs/sdks/javascript/) or [Python](https://stormedo.com/docs/sdks/python/) guide. Direct HTTP uses the snake-case `deliver_at` field with an RFC 3339 string. Use the JSON [advanced endpoint](https://stormedo.com/docs/api-reference/requests/) to avoid query-string escaping.

## Timing rules

- Specify only one of `delay` and `deliver_at`.
- Relative delays are whole seconds from one second through 30 days.
- Absolute times must be within 30 days before or after the server’s current time. An allowed past timestamp runs immediately.
- A scheduled time is when delivery becomes eligible to run, not a guarantee of exact destination arrival time.
- The timeout applies separately to each outbound attempt. It does not include the scheduled wait.

## Inspect or cancel

Open the request in the dashboard, or call `GET /requests/{request_id}` with the same project key. Expect `scheduled`, then `delivering`, then a final outcome. On an initial `404`, wait briefly and retry the read a bounded number of times.

To stop it, call `POST /requests/{request_id}/cancel`. A `202` means the cancellation signal was accepted. Inspect until the state becomes `cancelled`; an attempt already in flight can still complete. See [Cancel and replay](https://stormedo.com/docs/api-reference/request-actions/).
