B2B Saas Authentication

/

API reference

/

Discovery

/

Create Organization via Discovery

Create Organization via Discovery

POSThttps://test.stytch.com/v1/b2b/discovery/organizations/create

If an end user does not want to join any already-existing Organization, or has no possible Organizations to join, this endpoint can be used to create a new Organization and Member.

This operation consumes the Intermediate Session.

This endpoint will also create an initial Member Session for the newly created Member.

The Member created by this endpoint will automatically be granted the stytch_admin Role. See the RBAC guide for more details on this Role.

If the new Organization is created with a mfa_policy of REQUIRED_FOR_ALL, the newly created Member will need to complete an MFA step to log in to the Organization. The intermediate_session_token will not be consumed and instead will be returned in the response. The intermediate_session_token can be passed into the OTP SMS Authenticate endpoint to complete the MFA step and acquire a full member session. The intermediate_session_token can also be used with the Exchange Intermediate Session endpoint or the Create Organization via Discovery endpoint to join a different Organization or create a new one. The session_duration_minutes and session_custom_claims parameters will be ignored.


Body parameters


intermediate_session_token*string

session_duration_minutesint

session_custom_claimsmap<string, any>

organization_namestring

organization_slugstring

organization_logo_urlstring

trusted_metadataobject

email_jit_provisioningstring

email_invitesstring

email_allowed_domainsarray[strings]

sso_jit_provisioningstring

auth_methodsstring

allowed_auth_methodsarray[strings]

mfa_methodsstring

allowed_mfa_methodsarray[strings]

mfa_policystring

rbac_email_implicit_role_assignmentsarray[object]

oauth_tenant_jit_provisioningstring

allowed_oauth_tenantsobject

Response fields


request_idstring

status_codeint

member_idstring

mfa_requiredobject

primary_requiredobject

intermediate_session_tokenstring

member_authenticatedboolean

session_tokenstring

session_jwtstring

member_sessionobject

memberobject

organizationobject
curl --request POST \
  --url https://test.stytch.com/v1/b2b/discovery/organizations/create \
  -u 'PROJECT_ID:SECRET' \
  -H 'Content-Type: application/json' \
  -d '{
    "intermediate_session_token": "SeiGwdj5lKkrEVgcEY3QNJXt6srxS3IK2Nwkar6mXD4=",
    "organization_name": "Example Org Inc.",
    "organization_slug": "example-org"
  }'

RESPONSE

200
{
	"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
	"status_code": 200,
	"member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
	"session_token": "mZAYn5aLEqKUlZ_Ad9U_fWr38GaAQ1oFAhT8ds245v7Q",
	"session_jwt": "eyJ...",
	"intermediate_session_token": "",
	"member_authenticated": true,
	"mfa_required": null,
	"primary_required": null,
    "member_session": {...},
    "member": {...},
    "organization": {...}
}

Common Error Types