# pushSubscriptions.update

Verify or extend a push subscription.

The two mutations a subscription supports (RFC 8620 §7.2): echoing back the `verificationCode` the handshake push delivered (which is what arms the subscription: a wrong code is refused, never silently accepted, or an unproven endpoint would start receiving state), and extending `expires` (capped 30 days out). Requires a mailbox app password (`oemp_…`): subscriptions belong to the credential that creates them, so account and system keys are refused with 403 `mailbox_credential_required`.

```ts
openemail.pushSubscriptions.update(
  id: string,
  body: PushSubscriptionsUpdateBody,
  options?: CallOptions,
): ApiPromise<PushSubscription>
```

It calls `PATCH /push-subscriptions/{id}`: [Verify or extend a push subscription](/docs/api/push/patch_PushSubscriptionUpdate) in the API reference.

## Example

```ts
const pushSubscription = await openemail.pushSubscriptions.update(id, { verificationCode: '01J9MBX7F4Q2K9T3W6PUSHCODE' })
```

## Arguments

| Argument | Type | Description |
| --- | --- | --- |
| `id` | `string` | Push subscription ULID. The path's `{id}`. |
| `body` | [`PushSubscriptionsUpdateBody`](#pushsubscriptionsupdatebody) | The request's body. |

## Options

It takes no options of its own. Every call also takes `signal`, `timeout`, `retry` and `headers`, which say how that one call is sent ([call options](/docs/sdks/typescript/calling-methods#call-options)).

## Answer

Awaited, it is the API's JSON, [`PushSubscription`](/docs/sdks/typescript/types/push-subscription). It is an [`ApiPromise`](/docs/sdks/typescript/responses): `.withResponse()` gives the same with the `Response` it came in, for its headers.

## Errors

| Status | What it means |
| --- | --- |
| `400` | validation_failed, or invalid_verification_code |
| `401` | unauthorized: the bearer credential is missing, malformed, expired, or revoked. Carries a `WWW-Authenticate: Bearer` challenge |
| `403` | mailbox_credential_required |
| `404` | No such subscription for THIS credential (another credential's ids are indistinguishable from absent), or it expired |
| `413` | too_large: JSON request body exceeds 1 MiB or 500,000 values (object keys included), checked before parsing |
| `503` | temporary_failure (with Retry-After): under the object directory, the account's identity census could not be updated just now, so the write that would move it was not made; retry the same request after the Retry-After window. A request carrying both verificationCode and expires applies them as two writes, so its verification can already stand when the expiry is the write refused: the retry converges (a verified subscription accepts its code again, and the expiry then applies) |

A failed call rejects with a [`RequestError`](/docs/sdks/typescript/errors): its `status`, and its `code`, the API's `error`. Decide on the code: one status covers several.

## Types

### PushSubscriptionsUpdateBody

```ts
/** The body of `pushSubscriptions.update`. */
type PushSubscriptionsUpdateBody = {
  /** New expiry in epoch seconds; the server caps it 30 days out */
  expires?: number
  /** The code delivered inside the PushVerification push */
  verificationCode?: string
}
```

It names these types of the API, each on a page of its own: [`PushSubscription`](/docs/sdks/typescript/types/push-subscription).
