<!-- ZenPays documentation · https://docs.zenpayz.com/docs/rest-api/endpoints/billing/payment-links/update-payment-link -->

# Update Payment Link

Update an existing payment link. Only provided fields will be updated.

<EndpointHeader verb="PUT" path="/merchant/api/v1/payment-links/:linkId" />

## Request

### Headers

<ParamTable
  label="Header"
  rows={[
    { name: "Authorization", required: true, desc: "`Bearer {api_key}`" },
    { name: "X-Signature", required: true, desc: "HMAC-SHA256 signature" },
    { name: "X-Timestamp", required: true, desc: "ISO 8601 timestamp" },
    { name: "X-Secret-Salt", required: true, desc: "Secret salt for HMAC validation" },
    { name: "Content-Type", required: true, desc: "`application/json`" },
  ]}
/>

### Path Parameters

<ParamTable
  rows={[
    { name: "linkId", type: "string", required: true, desc: "The payment link ID (e.g. `pl_a1b2c3d4e5f6g7h8`)" },
  ]}
/>

### Body Parameters

<ParamTable
  rows={[
    { name: "title", type: "string", desc: "Payment link title (1-255 characters)" },
    { name: "description", type: "string", desc: "Payment link description" },
    { name: "amount", type: "number", desc: "Payment amount (minimum 0.01)" },
    { name: "currency", type: "string", desc: "Currency code" },
    { name: "usageType", type: "string", desc: "Usage type. One of `SINGLE`, `MULTI`" },
    { name: "status", type: "string", desc: "Link status. One of `ACTIVE`, `INACTIVE`, `EXPIRED`" },
    { name: "maxUses", type: "number", desc: "Maximum number of uses (minimum 1)" },
    { name: "expiresAt", type: "string", desc: "Expiration date (ISO 8601)" },
    { name: "invoiceIds", type: "string[]", desc: "Array of associated invoice IDs" },
  ]}
/>

## Response

### Success (200 OK)

```json
{
  "success": true,
  "data": {
    "linkId": "pl_a1b2c3d4e5f6g7h8",
    "title": "Pro Plan Payment - Updated",
    "description": "Payment for Pro Plan subscription (updated)",
    "amount": 3999,
    "currency": "INR",
    "status": "ACTIVE",
    "usageType": "MULTI",
    "maxUses": 10,
    "usageCount": 0,
    "expiresAt": "2024-03-15T23:59:59.000Z",
    "productId": "prod_a1b2c3d4e5f6g7h8",
    "customerId": null,
    "invoiceId": null,
    "paymentUrl": "https://pay.zenpayz.com/pl_a1b2c3d4e5f6g7h8",
    "shortCode": "ZP-XYZ789",
    "shortUrl": "https://pay.zenpayz.com/s/ZP-XYZ789",
    "metadata": {},
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-01-16T14:20:00.000Z"
  },
  "message": "Payment link updated successfully",
  "error": null,
  "meta": {
    "request_id": "req_xxxxx",
    "timestamp": "2024-01-16T14:20:00.000Z",
    "processing_time_ms": 40,
    "api_version": "v1",
    "endpoint": "PUT /payment-links/:linkId",
    "user_type": "merchant"
  }
}
```

### Error Responses

<ErrorTable
  rows={[
    { code: "VALIDATION_ERROR", status: "400", message: "Invalid request parameters" },
    { code: "UNAUTHORIZED", status: "401", message: "Invalid API key" },
    { code: "PAYMENT_LINK_NOT_FOUND", status: "404", message: "Payment link does not exist" },
  ]}
/>

<CodeRail>

## Examples

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

```bash
curl -X PUT https://api.zenpayz.com/merchant/api/v1/payment-links/pl_a1b2c3d4e5f6g7h8 \
  -H "Authorization: Bearer zp_test_xxxxx" \
  -H "X-Timestamp: 2024-01-16T14:20:00.000Z" \
  -H "X-Signature: a1b2c3d4e5f6..." \
  -H "X-Secret-Salt: your_secret_salt" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Pro Plan Payment - Updated",
    "amount": 3999,
    "usageType": "MULTI",
    "maxUses": 10,
    "expiresAt": "2024-03-15T23:59:59.000Z"
  }'
```

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

```javascript
const response = await fetch('https://api.zenpayz.com/merchant/api/v1/payment-links/pl_a1b2c3d4e5f6g7h8', {
  method: 'PUT',
  headers: {
    'Authorization': `Bearer ${apiKey}`,
    'X-Timestamp': timestamp,
    'X-Signature': signature,
    'X-Secret-Salt': secretSalt,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    title: 'Pro Plan Payment - Updated',
    amount: 3999,
    usageType: 'MULTI',
    maxUses: 10,
    expiresAt: '2024-03-15T23:59:59.000Z',
  }),
});

const result = await response.json();
console.log(result.data.amount); // 3999
console.log(result.data.usageType); // "MULTI"
```

  </TabItem>
  <TabItem value="sdk" label="SDK">

```javascript
const link = await zenpays.paymentLinks.update('pl_a1b2c3d4e5f6g7h8', {
  title: 'Pro Plan Payment - Updated',
  amount: 3999,
  usageType: 'MULTI',
  maxUses: 10,
  expiresAt: '2024-03-15T23:59:59.000Z',
});

console.log(link.amount); // 3999
console.log(link.usageType); // "MULTI"
```

  </TabItem>
</Tabs>

</CodeRail>

## Related Endpoints

- [Get Payment Link](/docs/rest-api/endpoints/billing/payment-links/get-payment-link)
- [Deactivate Payment Link](/docs/rest-api/endpoints/billing/payment-links/deactivate-payment-link)
- [List Payment Links](/docs/rest-api/endpoints/billing/payment-links/list-payment-links)
