# setTenantExpiry

Audience: Developer

Sets or clears the tenant's expiry timestamp.

Sets or clears the tenant's expiry timestamp. Pass input.expiresAt
as null to clear. Soft-deleted (disabled) tenants are not visible
to this mutation — call restoreTenant first (it accepts an optional
new expiry). Returns an error when the tenant does not exist
(including the disabled case). The value is written directly to
tenant.expires_at; the periodic tenant-expiry-check workflow
soft-deletes the tenant once the timestamp is in the past.
Idempotent on the already-at-target-state cases (clear against
empty, set matching the current value).

The target tenant is named by input.tenantId. System caller required
(PYCK_SERVICE_TOKEN): the expiry is the deadline an operator imposes on
the tenant, and a tenant admin able to move it would outlive the
operator's decision on its own. The Zitadel root organization is refused
as the target: it is not a tenant.

**Served by:** [management](https://docs.pyck.cloud/dev/api/services/management.md)

## Arguments

| Name | Type |
| --- | --- |
| `input` | [SetTenantExpiryInput](https://docs.pyck.cloud/dev/api/inputs/settenantexpiryinput.md)! |

## Returns

[SetTenantExpiryResponse](https://docs.pyck.cloud/dev/api/types/settenantexpiryresponse.md)!

## Example

Sets or clears the tenant's expiry timestamp. Pass null to clear. System role required. The value is written directly to tenant.expires_at; the periodic tenant-expiry-check workflow soft-deletes the tenant once the timestamp is reached. Returns an error when the tenant does not exist; soft-deleted tenants are invisible to this mutation. Idempotent on the already-at-target-state cases.

```graphql
mutation SetTenantExpiry($input: SetTenantExpiryInput!) {
  setTenantExpiry(input: $input) {
    success
  }
}
```

**Variables**

```json
{
  "input": {
    "expiresAt": "<RFC3339 timestamp, or null to clear>",
    "tenantId": "<tenant ID>"
  }
}
```
