Endpoint
POST /v1/dpdp/consent-records/:recordId/withdraw
Authentication
Requires a developer API key in theAuthorization header.
Request Headers
| Header | Value |
|---|---|
Authorization | Bearer <api_key> |
Content-Type | application/json |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
recordId | string | Yes | The consent record ID to withdraw |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
reason | string | Yes | Reason for consent withdrawal |
revokeGrant | boolean | No | If true, revokes the underlying Grantex grant |
deleteProcessedData | boolean | No | If true, anonymizes audit entries related to this consent (DPDP Section 6(6), GDPR Article 17) |
Example Request
curl -X POST https://api.grantex.dev/v1/dpdp/consent-records/cr_01HXYZ.../withdraw \
-H "Authorization: Bearer gx_..." \
-H "Content-Type: application/json" \
-d '{
"reason": "No longer wish to share data for analytics",
"revokeGrant": true,
"deleteProcessedData": true
}'
Response — 200 OK
{
"recordId": "cr_01HXYZ...",
"status": "withdrawn",
"withdrawnAt": "2026-04-05T14:00:00.000Z",
"grantRevoked": true,
"dataDeleted": true
}
Response Fields
| Field | Type | Description |
|---|---|---|
recordId | string | The consent record ID |
status | string | Updated status: withdrawn |
withdrawnAt | string | ISO-8601 timestamp of withdrawal |
grantRevoked | boolean | Whether the underlying grant was revoked |
dataDeleted | boolean | Whether processed data was anonymized |
Error Responses
| Status | Code | Description |
|---|---|---|
| 400 | BAD_REQUEST | Missing reason field |
| 401 | UNAUTHORIZED | Invalid or missing API key |
| 404 | NOT_FOUND | Consent record not found |
| 409 | ALREADY_WITHDRAWN | Consent has already been withdrawn |
SDK Examples
import Grantex from '@grantex/sdk';
const grantex = new Grantex({ apiKey: 'gx_...' });
const result = await grantex.dpdp.withdrawConsent('cr_01HXYZ...', {
reason: 'No longer wish to share data',
revokeGrant: true,
deleteProcessedData: true,
});
from grantex import Grantex
grantex = Grantex(api_key="gx_...")
result = grantex.dpdp.withdraw_consent(
record_id="cr_01HXYZ...",
reason="No longer wish to share data",
revoke_grant=True,
delete_processed_data=True,
)