---
title: "Idempotently synchronize an external billing period"
description: "POST /admin/v1/workspace-accesses/{accessId}/billing-periods/sync — Idempotently synchronize an external billing period"
---

> Documentation Index
> Fetch the complete documentation index at: https://nexus.microvoid.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Idempotently synchronize an external billing period

## Endpoint

```http
POST /admin/v1/workspace-accesses/{accessId}/billing-periods/sync
```

Operation ID: `syncWorkspaceAccessBillingPeriod`

## Authentication

Send a Nexus Management Key as `Authorization: Bearer <management-key>`. This credential is control-plane only.

## Idempotency

This operation requires `Idempotency-Key`. Reuse the same caller-owned value only when retrying the same logical command.

## Request

### Parameters

| Name              | Location | Required | Schema   | Description                 |
| ----------------- | -------- | -------- | -------- | --------------------------- |
| `accessId`        | path     | Yes      | `string` | —                           |
| `Idempotency-Key` | header   | Yes      | `string` | Workspace-scoped retry key. |

### application/json body

Required: **Yes**

Type: `SyncBillingPeriodDto`

| Field                    | Required | Type                                                                                               | Description |
| ------------------------ | -------- | -------------------------------------------------------------------------------------------------- | ----------- |
| `planId`                 | Yes      | `string`                                                                                           | —           |
| `provider`               | Yes      | `string (STRIPE \| CREEM)`                                                                         | —           |
| `externalSubscriptionId` | Yes      | `string`                                                                                           | —           |
| `externalCustomerId`     | No       | `string`                                                                                           | —           |
| `status`                 | Yes      | `string (ACTIVE \| TRIALING \| PAST_DUE \| PAUSED \| CANCELED \| UNPAID \| INCOMPLETE \| UNKNOWN)` | —           |
| `periodStart`            | Yes      | `string`                                                                                           | —           |
| `periodEnd`              | Yes      | `string`                                                                                           | —           |
| `cancelAtPeriodEnd`      | No       | `boolean`                                                                                          | —           |
| `sourceEventId`          | No       | `string`                                                                                           | —           |

## Responses

| Status | Description | Content type     | Schema               |
| ------ | ----------- | ---------------- | -------------------- |
| `200`  | —           | application/json | `WorkspaceAccessDto` |

Only responses explicitly declared by the accepted Admin OpenAPI contract are shown. The current contract does not declare operation-specific error bodies; the SDK preserves any non-success status and body in [`AdminApiError`](/management-sdk/error-handling).

### `200` application/json schema

Type: `WorkspaceAccessDto`

| Field            | Required | Type                                                            | Description |
| ---------------- | -------- | --------------------------------------------------------------- | ----------- |
| `id`             | Yes      | `string`                                                        | —           |
| `workspaceId`    | Yes      | `string`                                                        | —           |
| `userId`         | Yes      | `string`                                                        | —           |
| `externalUserId` | Yes      | `string`                                                        | —           |
| `planId`         | Yes      | `string`                                                        | —           |
| `status`         | Yes      | `string (PENDING \| ACTIVE \| SUSPENDED \| EXPIRED \| REVOKED)` | —           |
| `accessStartsAt` | Yes      | `string / date-time`                                            | —           |
| `accessEndsAt`   | No       | `string / date-time`                                            | —           |
| `metadata`       | No       | `object`                                                        | —           |

## Examples

### TypeScript Management SDK

`NexusAdminClient.syncWorkspaceAccessBillingPeriod` uses `AdminOperationInput<"syncWorkspaceAccessBillingPeriod">` and returns `Promise<AdminOperationOutput<"syncWorkspaceAccessBillingPeriod">>`.

```ts
import { NexusAdminClient } from '@nexus/sdk-typescript';

const nexus = new NexusAdminClient({
  baseUrl: 'https://nexus.microvoid.io',
  managementKey: process.env.NEXUS_MANAGEMENT_KEY,
});

const result = await nexus.syncWorkspaceAccessBillingPeriod({
  path: {
    accessId: '533c4e1e-2823-4349-86b9-d6f1a869a2ca',
  },
  headers: {
    'Idempotency-Key': 'operation:stable-key',
  },
  body: {
    planId: '533c4e1e-2823-4349-86b9-d6f1a869a2ca',
    provider: 'STRIPE',
    externalSubscriptionId: '533c4e1e-2823-4349-86b9-d6f1a869a2ca',
    status: 'ACTIVE',
    periodStart: 'string',
    periodEnd: 'string',
  },
});
```

### Fetch

```ts
const response = await fetch(
  'https://nexus.microvoid.io/admin/v1/workspace-accesses/533c4e1e-2823-4349-86b9-d6f1a869a2ca/billing-periods/sync',
  {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.NEXUS_MANAGEMENT_KEY}`,
      'Idempotency-Key': 'operation:stable-key',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      planId: '533c4e1e-2823-4349-86b9-d6f1a869a2ca',
      provider: 'STRIPE',
      externalSubscriptionId: '533c4e1e-2823-4349-86b9-d6f1a869a2ca',
      status: 'ACTIVE',
      periodStart: 'string',
      periodEnd: 'string',
    }),
  },
);

if (!response.ok) throw new Error(`Nexus request failed: ${response.status}`);
```

### curl

```bash
curl --request POST \
  "https://nexus.microvoid.io/admin/v1/workspace-accesses/533c4e1e-2823-4349-86b9-d6f1a869a2ca/billing-periods/sync" \
  --header "Authorization: Bearer ${NEXUS_MANAGEMENT_KEY}" \
  --header "Idempotency-Key: operation:stable-key" \
  --header "Content-Type: application/json" \
  --data "{\"planId\":\"533c4e1e-2823-4349-86b9-d6f1a869a2ca\",\"provider\":\"STRIPE\",\"externalSubscriptionId\":\"533c4e1e-2823-4349-86b9-d6f1a869a2ca\",\"status\":\"ACTIVE\",\"periodStart\":\"string\",\"periodEnd\":\"string\"}"
```

## Related guide

- [Time boundaries](/docs/give-users-access/time-boundaries)
- [API Reference overview](/api-reference)

Source: https://nexus.microvoid.io/api-reference/admin/billing/sync-workspace-access-billing-period/index.mdx
