Create M2M Client

POSThttps://test.stytch.com/v1/m2m/clients

Creates a new M2M Client. On initial client creation, you may pass in a custom client_id or client_secret to import an existing M2M client. If you do not pass in a custom client_id or client_secret, one will be generated automatically. The client_id must be unique among all clients in your project.

Important: This is the only time you will be able to view the generated client_secret in the API response. Stytch stores a hash of the client_secret and cannot recover the value if lost. Be sure to persist the client_secret in a secure location. If the client_secret is lost, you will need to trigger a secret rotation flow to receive another one.


Body parameters


client_idstring

client_secretstring

client_namestring

client_descriptionstring

scopesarray[strings]

trusted_metadataobject

Response fields


status_codeint

request_idstring

m2m_clientobject
curl --request POST \
	--url https://test.stytch.com/v1/m2m/clients \
	-u 'PROJECT_ID:SECRET' \
	-H 'Content-Type: application/json' \
	-d '{
		"client_id": "m2m-client-test-d731954d-dab3-4a2b-bdee-07f3ad1be885",
		"client_secret": "NHQhc7ZqsXJVtgmN2MXr1etqsQrGAwJ-iBWNLKY7DzJj",
		"scopes": ["read:users", "write:users"]
	}'

RESPONSE

200
{
    "status_code": 200,
    "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
    "m2m_client": {
        "client_id":"m2m-client-test-d731954d-dab3-4a2b-bdee-07f3ad1be885",
        "client_secret":"NHQhc7ZqsXJVtgmN2MXr1etqsQrGAwJ-iBWNLKY7DzJj",
        "client_name":"Example client name",
        "client_description":"Example client description.",
        "client_secret_last_four":"DzJj",
        "next_client_secret_last_four":null,
        "status":"active",
        "scopes":["read:users","write:users"],
        "trusted_metadata":{}
    }
}