Docs

Add an origin pattern

POST
/projects/{project_id}/origins

Adds an origin pattern, a pattern and its kind, to the project's origins.

An origin pattern says which web origins the project accepts. A primary pattern must be an exact URL with no wildcard. A preview pattern may include a single DNS-label wildcard.

While the project has no patterns, it admits no origin except a loopback origin, so the first pattern you add opens it to the origins that pattern matches. Admitting an origin is not serving it: a new primary origin answers rel.not_deployed until the next deploy to primary (zitadel deploy).

Adding a pattern that already exists with the same kind is idempotent and answers 201 with the stored origin. If the pattern exists with the other kind, the request is refused with origin.kind_conflict: remove it with removeProjectOrigin (POST /projects/{project_id}/origins/remove), then add it again.

Authorization

headerAuthorizationBearer <token>

Scope: origin.write

Path Parameters

project_id*string

The project ID: the id that createProject (POST /projects) returns, which zitadel setup also prints as project_id.

Match^[a-zA-Z0-9_-]+$

Request Body

application/json
  1. body

One of a project's origins: a pattern and what it is for. A primary pattern is an exact origin (scheme and host, no *) that admits requests from the URLs it matches. A preview pattern only bounds which URLs a preview deploy may register. It may include at most one * inside a single host label; * matches one or more characters, none of them a dot. A literal beats a wildcard. Unknown hosts are accepted as written. An empty list admits no origin except a loopback origin, which is admitted without a pattern.

A loopback origin is on the local machine: localhost, a name under .localhost, or a loopback IP such as 127.0.0.1 or [::1], on any port and over http or https. It is never a preview URL.

pattern*string

The origin pattern: an exact origin for primary, or an origin with at most one * for preview.

kind*string

What the pattern is for: primary admits requests from the URLs it matches, preview bounds which URLs a preview deploy may register.

Value in"primary""preview"

Response Body

The stored origin pattern.

application/json
  1. response

The origin pattern as the project stores it.

pattern*string

The origin pattern.

kind*string

What the pattern is for, primary or preview.

Value in"primary""preview"
Example Request
import { configureZitadel, getApi } from "@zitadel/api/config";import { setApiCsrfToken } from "@zitadel/api/runtime/auth";// In the browser, through the SDK proxy: the session cookie authenticates the call.const client = getApi(configureZitadel({ projectId: "proj_01KWH1P4MYS7F0N9WD3P2E4YM5" }));// A write the session cookie authenticates carries the session's CSRF token.setApiCsrfToken((await client.getMySessionCsrfToken()).csrf_token);const projectOrigin = await client.addProjectOrigin(  "proj_01KWH1P4MYS7F0N9WD3P2E4YM5",  { pattern: "string", kind: "primary" },);
Example Response
{  "pattern": "string",  "kind": "primary"}

Was this helpful?