<!-- ZenPays documentation · https://docs.zenpayz.com/docs/rest-api/endpoints/ramp/update-ramp-intent-status -->

# Update Ramp Intent Status

Manually update the status of a ramp intent. This is useful for cancelling intents from your frontend or marking them as completed after verifying a transaction.

<EndpointHeader verb="PATCH" path="/payment/api/v1/ramp-intents/:intentId/status" />

## Request

### Headers

<ParamTable
  label="Header"
  rows={[
    { name: "Content-Type", required: true, desc: "`application/json`" },
    { name: "x-request-id", desc: "Custom request ID for tracing" },
  ]}
/>

:::note Public Endpoint
This endpoint does not require authentication headers.
:::

### Path Parameters

<ParamTable
  rows={[
    { name: "intentId", type: "string", required: true, desc: "The ramp intent ID" },
  ]}
/>

### Body Parameters

<ParamTable
  rows={[
    { name: "status", type: "string", required: true, desc: "Target status: `active`, `completed`, or `cancelled`" },
  ]}
/>

## Status Transitions

Only certain transitions are allowed. Attempting an invalid transition returns a `400` error.

| Current Status | Allowed Transitions |
|----------------|-------------------|
| `created` | `active`, `cancelled`, `expired` |
| `active` | `completed`, `cancelled`, `expired` |
| `completed` | — (terminal) |
| `expired` | — (terminal) |
| `cancelled` | — (terminal) |

```
    ┌──────────┐
    │ created  │
    └──┬───┬───┘
       │   │
  active   cancelled / expired
       │
    ┌──▼──────┐
    │ active  │
    └──┬──┬───┘
       │  │
completed  cancelled / expired

  (completed, expired, cancelled are terminal)
```

## Response

### Success (200 OK)

```json
{
  "success": true,
  "data": {
    "intentId": "ri_1710345678000_a1b2c3d4e5f6g7h8",
    "status": "cancelled"
  },
  "message": "Ramp intent status updated"
}
```

### Response Fields

<ParamTable
  rows={[
    { name: "intentId", type: "string", desc: "The intent ID" },
    { name: "status", type: "string", desc: "The updated status" },
  ]}
/>

### Error Responses

<ErrorTable
  rows={[
    { code: "BAD_REQUEST", status: "400", message: "Invalid status transition (e.g. `completed` → `active`)" },
    { code: "NOT_FOUND", status: "404", message: "Intent with the given ID does not exist" },
  ]}
/>

<CodeRail>

## Examples

<Tabs groupId="language">
  <TabItem value="curl" label="cURL" default>

```bash
# Cancel an intent
curl -X PATCH https://api.zenpayz.com/payment/api/v1/ramp-intents/ri_1710345678000_a1b2c3d4e5f6g7h8/status \
  -H "Content-Type: application/json" \
  -d '{ "status": "cancelled" }'

# Mark as completed
curl -X PATCH https://api.zenpayz.com/payment/api/v1/ramp-intents/ri_1710345678000_a1b2c3d4e5f6g7h8/status \
  -H "Content-Type: application/json" \
  -d '{ "status": "completed" }'
```

  </TabItem>
  <TabItem value="javascript" label="JavaScript">

```javascript
const intentId = 'ri_1710345678000_a1b2c3d4e5f6g7h8';

// Cancel an intent (e.g. user clicks "Cancel" on your checkout page)
const response = await fetch(
  `https://api.zenpayz.com/payment/api/v1/ramp-intents/${intentId}/status`,
  {
    method: 'PATCH',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ status: 'cancelled' }),
  }
);

const { data } = await response.json();
console.log(`Intent ${data.intentId} is now ${data.status}`);
```

  </TabItem>
  <TabItem value="python" label="Python">

```python
import requests

intent_id = "ri_1710345678000_a1b2c3d4e5f6g7h8"

response = requests.patch(
    f"https://api.zenpayz.com/payment/api/v1/ramp-intents/{intent_id}/status",
    json={"status": "cancelled"},
)

data = response.json()["data"]
print(f"Intent {data['intentId']} is now {data['status']}")
```

  </TabItem>
</Tabs>

</CodeRail>

## Next Steps

- [Get Ramp Intent](/docs/rest-api/endpoints/ramp/get-ramp-intent) — Check current intent state
- [List Ramp Intents](/docs/rest-api/endpoints/ramp/list-ramp-intents) — Browse all intents
- [Create Ramp Intent](/docs/rest-api/endpoints/ramp/create-ramp-intent) — Create a new intent
