curl --request POST \
--url https://api.mage.space/v1/requests/{request_id}/cancel \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.mage.space/v1/requests/{request_id}/cancel"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.mage.space/v1/requests/{request_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"request_id": "d7e6c0f3-6699-4f6c-bb45-2ad7fd9158ff",
"status": "cancelled",
"architecture": "flux2",
"model_id": "flux2-dev",
"created_at": "2026-09-17T14:52:48.000Z",
"updated_at": "2026-09-17T14:52:55.000Z",
"billing": {
"mode": "gems",
"gems_charged": 40
},
"result": null,
"error": null,
"status_url": "https://api.mage.space/v1/requests/d7e6c0f3-6699-4f6c-bb45-2ad7fd9158ff/status",
"cancel_url": "https://api.mage.space/v1/requests/d7e6c0f3-6699-4f6c-bb45-2ad7fd9158ff/cancel"
}{
"error": {
"code": "unauthorized",
"message": "The API key is invalid or has been revoked."
}
}{
"error": {
"code": "request_not_found",
"message": "No request with this id belongs to the account."
}
}{
"error": {
"code": "request_finished",
"message": "The request has already finished and cannot be cancelled."
}
}{
"error": {
"code": "internal_error",
"message": "Something went wrong on our side. Retry, and contact support if it persists."
}
}Cancel request
Stop a live Mage API request through its cancel URL. Gems are not refunded on cancellation.
curl --request POST \
--url https://api.mage.space/v1/requests/{request_id}/cancel \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.mage.space/v1/requests/{request_id}/cancel"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.mage.space/v1/requests/{request_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"request_id": "d7e6c0f3-6699-4f6c-bb45-2ad7fd9158ff",
"status": "cancelled",
"architecture": "flux2",
"model_id": "flux2-dev",
"created_at": "2026-09-17T14:52:48.000Z",
"updated_at": "2026-09-17T14:52:55.000Z",
"billing": {
"mode": "gems",
"gems_charged": 40
},
"result": null,
"error": null,
"status_url": "https://api.mage.space/v1/requests/d7e6c0f3-6699-4f6c-bb45-2ad7fd9158ff/status",
"cancel_url": "https://api.mage.space/v1/requests/d7e6c0f3-6699-4f6c-bb45-2ad7fd9158ff/cancel"
}{
"error": {
"code": "unauthorized",
"message": "The API key is invalid or has been revoked."
}
}{
"error": {
"code": "request_not_found",
"message": "No request with this id belongs to the account."
}
}{
"error": {
"code": "request_finished",
"message": "The request has already finished and cannot be cancelled."
}
}{
"error": {
"code": "internal_error",
"message": "Something went wrong on our side. Retry, and contact support if it persists."
}
}409 request_finished. Cancelling one that is already cancelled does nothing and returns its state.Authorizations
An API key from Settings → API, sent as Authorization: Bearer mage_sk_…. Keys are for server-side code only.
Path Parameters
The request_id from the submit response.
Response
The request's state after the cancellation.
The request id, also the id in status_url and cancel_url.
queued and in_progress are live; completed, failed, and cancelled are final.
queued, in_progress, completed, failed, cancelled The architecture the request generates with.
The model variant, when the architecture has variants.
When the request was accepted.
When the request last changed.
Show child attributes
Show child attributes
The output once status is completed, else null.
Show child attributes
Show child attributes
Why the request failed once status is failed, else null.
Show child attributes
Show child attributes
Poll this URL for the request.
POST to this URL to stop the request.

