Session

2 endpointsEnglish only

Sign in with email and password

post/authenticateexperimentalNo authentication

The only way a script obtains a session today. On success sets two cookies: `session` (httpOnly, carries the session id) and `csrf-token` (readable by JavaScript). Every mutating request afterwards - anything but GET, HEAD and OPTIONS - must send the `csrf-token` cookie's value back as the `X-CSRF-Token` header, or it is refused with 403; GET requests need only the `session` cookie. A cookie jar makes this workable from a script; a browser on another origin cannot call it (no CORS, `SameSite=Lax` cookies). Responds 400 when the body fails validation and 401 when the email or password is wrong.

Rate limit: 10 requests per 900 seconds.

Request body

FieldTypeRequiredConstraintsDescription
emailstringYesformat: "email"-
passwordstringYes--
Example
{
  "email": "kamil@example.com",
  "password": "correct horse battery staple"
}

Responses

  • 200Success
    FieldTypeRequiredConstraintsDescription
    userAuthenticatedUserYes-The signed-in account, as returned by the endpoint that grants the session.
    Example
    {
      "user": {
        "uid": "uid-1",
        "email": "kamil@example.com",
        "name": "Kamil",
        "locale": "en"
      }
    }
  • 400The request body does not match the schema

    No body.

  • 401Not authenticated

    No body.

Example request

curl -X POST 'https://mercastra.cloud/api/authenticate' \
  -H 'Content-Type: application/json' \
  -d '{"email":"kamil@example.com","password":"correct horse battery staple"}'

End the caller's session

post/logoutexperimentalSession required

Revokes the session behind the `session` cookie and clears both auth cookies. Responds 403 when the CSRF token is missing or invalid.

Responses

  • 200Success

    No body.

  • 401Not authenticated

    No body.

  • 403Forbidden

    No body.

Example request

curl -X POST 'https://mercastra.cloud/api/logout' \
  -H 'Cookie: session=<session cookie>' \
  -H 'X-CSRF-Token: <csrf-token cookie value>'