Skip to content

Commit c1e8a19

Browse files
committed
Add POST /register docs
1 parent f839965 commit c1e8a19

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

docs/reference/auth/http.rst

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,86 @@ POST /register
2929

3030
Register a new user with email and password.
3131

32+
**Request Body (JSON):**
33+
34+
* ``email`` (string, required): The user's email address.
35+
* ``password`` (string, required): The user's desired password.
36+
* ``provider`` (string, required): The name of the provider to use (e.g., "emailpassword").
37+
* ``challenge`` (string, optional): A PKCE code challenge. This is required if the provider is configured with ``require_verification: false``.
38+
* ``redirect_to`` (string, optional): A URL to redirect to upon successful registration.
39+
* ``verify_url`` (string, optional): The base URL for the email verification link. If not provided, it defaults to ``<auth_server_base_url>/ui/verify``. The verification token will be appended as a query parameter to this URL.
40+
* ``redirect_on_failure`` (string, optional): A URL to redirect to if registration fails.
41+
42+
**Response:**
43+
44+
The behavior of the response depends on the request parameters and server-side provider configuration (specifically, ``require_verification``).
45+
46+
1. **Successful Registration with Email Verification Required:**
47+
48+
* This occurs if the provider has ``require_verification: true``.
49+
* A verification email is sent to the user.
50+
* If ``redirect_to`` is provided in the request:
51+
52+
* A 302 redirect to the ``redirect_to`` URL occurs.
53+
* The redirect URL will include ``identity_id`` and ``verification_email_sent_at`` as query parameters.
54+
55+
* If ``redirect_to`` is NOT provided:
56+
57+
* A 201 Created response is returned with a JSON body:
58+
59+
.. code-block:: json
60+
61+
{
62+
"identity_id": "...",
63+
"verification_email_sent_at": "YYYY-MM-DDTHH:MM:SS.ffffffZ"
64+
}
65+
66+
2. **Successful Registration with Email Verification NOT Required (PKCE Flow):**
67+
68+
* This occurs if the provider has ``require_verification: false``. The ``challenge`` parameter is mandatory in the request.
69+
* A verification email is still sent, but it's not required for the user to verify their email to get an access token.
70+
* If ``redirect_to`` is provided in the request:
71+
72+
* A 302 redirect to the ``redirect_to`` URL occurs.
73+
* The redirect URL will include ``code`` (the PKCE authorization code) and ``provider`` as query parameters.
74+
75+
* If ``redirect_to`` is NOT provided:
76+
77+
* A 201 Created response is returned with a JSON body:
78+
79+
.. code-block:: json
80+
81+
{
82+
"code": "...",
83+
"provider": "..."
84+
}
85+
86+
3. **Registration Failure:**
87+
88+
* If ``redirect_on_failure`` is provided in the request and is an allowed URL:
89+
90+
* A 302 redirect to the ``redirect_on_failure`` URL occurs.
91+
* The redirect URL will include ``error`` (a description of the error) and ``email`` (the submitted email) as query parameters.
92+
93+
* Otherwise (no ``redirect_on_failure`` or it's not allowed):
94+
95+
* An HTTP error response (e.g., 400 Bad Request, 500 Internal Server Error) is returned with a JSON body describing the error. For example:
96+
97+
.. code-block:: json
98+
99+
{
100+
"message": "Error description",
101+
"type": "ErrorType",
102+
"code": "ERROR_CODE"
103+
}
104+
105+
**Common Error Scenarios:**
106+
107+
* Missing ``provider`` in the request.
108+
* Missing ``challenge`` in the request when the provider has ``require_verification: false``.
109+
* Email already exists.
110+
* Invalid password (e.g., too short, if policies are enforced).
111+
32112
POST /authenticate
33113
------------------
34114

0 commit comments

Comments
 (0)