/v1/apps/{app_id}/cloneAuthCreate a second app in the same workspace whose configuration matches this one — the "staging app" flow. Copies the auth config, roles, permissions, notification settings and the webhook target (with a NEW signing secret), and optionally tenants. Never copies credentials, end-users, sessions, signing keys, federated provider configs or audit history.
Path parameters
app_id*stringId of the app.
Headers
Idempotency-KeystringStripe-style idempotency key. A clone mints JWKS keys, copies the RBAC model and returns a webhook signing secret exactly once; a retry without this header creates a second app and a second secret the customer never sees. 24h TTL.
Request body
slug*stringSlug for the new app. Must be free — a slug still live as a rename alias counts as taken.
Example: "acme-app-staging"
environment*enum (3)Environment the clone is. Usually `staging`.
Example: "staging"
display_namestringDisplay name for the clone. Defaults to the source's, which is what makes the console group the two together.
Example: "Acme"
copy_tenantsbooleanAlso copy the source app's tenants (slug, display name, metadata, status). Memberships are NEVER copied — they point at end-user accounts, which are not copied either, so a cloned tenant is an empty tenant. Default false.
Response · 201 Clone created. `webhook_signing_secret` is returned exactly once.
app*objectid*stringUnique identifier of the app.
slug*stringURL-safe identifier of the app, unique within its parent.
Example: "acme-app"
display_name*stringHuman-readable name of the app.
Example: "Acme"
workspace_id*stringOwning workspace UUID.
status*objectApp status: `active`, `suspended` (sign-ins refused) or `archived`.
environment*objectWhich environment this app IS. One app is one environment — there is no switch; a staging app is a separate app created via `POST /v1/apps/:appId/clone`. Set at create time and never changed afterwards. Every app that predates this field is `production`.
Example: "production"
created_by*stringAccount that created the app.
metadata*objectFree-form JSON object you attach to the app; returned as stored.
created_at*string · date-timeWhen the app was created (ISO 8601).
updated_at*string · date-timeWhen the app was last changed (ISO 8601).
audit_retention_days*numberDays of `audit_log` history kept for this app. A nightly job deletes rows older than this. 30-3650.
Example: 365
webhook_attempt_retention_days*numberDays of outbound-webhook delivery-attempt history kept for this app. 7-365.
Example: 30
copied*objectWhat came across: counts for roles, permissions, role_permissions and tenants, plus booleans for notification settings and the webhook.
providers_to_configure*arrayFederated providers configured on the source that the clone does NOT have. A provider config IS its secret (Apple private key, OAuth client secret), so there is nothing safe to copy — configure these on the clone before using federated sign-in.
Example: ["apple","google"]
webhook_signing_secret*stringFreshly minted webhook signing secret for the clone, returned exactly ONCE. Null when the source had no webhook, or when its target no longer resolves safely. The source app's secret is never reused.
notes*arrayHuman-readable notes about anything deliberately skipped.
Example
Request
POST https://api.auth.productcraft.co/v1/apps/{app_id}/clone
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json
{
"slug": "acme-app-staging",
"environment": "staging",
"display_name": "Acme",
"copy_tenants": false
}import { Auth } from "@productcraft/auth";
// Admin routes read PRODUCTCRAFT_API_KEY; consumer routes need no key
const auth = new Auth();
const cloneApp = await auth.admin.app("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f").clone({ environment: "staging", slug: "acme-app-staging" });auth.admin.app(…).clone(params, options?): Auth.CloneApp
Response
{
"app": {
"id": "string",
"slug": "acme-app",
"display_name": "Acme",
"workspace_id": "string",
"status": {},
"environment": "production",
"created_by": "string",
"metadata": {},
"created_at": "2026-01-01T00:00:00.000Z",
"updated_at": "2026-01-01T00:00:00.000Z",
"audit_retention_days": 365,
"webhook_attempt_retention_days": 30
},
"copied": {},
"providers_to_configure": [
"apple",
"google"
],
"webhook_signing_secret": "string",
"notes": [
"string"
]
}