---
title: Start a sign-in
project: OpenAuth
version: 1.0
section: reference
language: en
license: MIT
url: https://totaljs.es/docs/openauth/1-0/reference/start-sign-in/
updated: 2026-11-19T09:22:05.212Z
---

# Start a sign-in

> POST / creates a sign-in session and returns the address to send the user to.

```http
POST /
x-token: YOUR_APP_TOKEN
Content-Type: application/json
```

## Token

Send an [app token](../../guides/app-tokens/) in the `x-token` header, or as the `token` query argument (`POST /?token=YOUR_APP_TOKEN`). The header keeps the token out of server logs.

## Body

| Field | Required | Meaning |
|---|---|---|
| `serviceid` | yes | The ID of the [extension](../../guides/extensions/), for example `facebook`. |
| `sessionid` | yes | Your own ID for this sign-in. OpenAuth returns it to you and you use it to read the profile. Make it unique and hard to guess, for example a UUID. |
| `url` | no | Where OpenAuth sends the user after signing in. OpenAuth adds `sessionid` to it: `?sessionid=...`, or `&sessionid=...` when the address already has a query. |

## Answer

`200` with the sign-in address as a JSON string:

```bash
curl -H "x-token: YOUR_APP_TOKEN" -H "Content-Type: application/json" \
  -d '{"serviceid":"facebook","sessionid":"7f3a9c21","url":"https://www.example.com/auth/"}' \
  https://auth.example.com/
```

```json
"https://auth.example.com/login/mwn8jzivbyr19ogt6g/"
```

Redirect the user's browser to that address within 15 minutes.

## When the user comes back

- With `url`: the browser arrives at `https://www.example.com/auth/?sessionid=7f3a9c21`. Check that the session ID is one your app started for this browser (for example, keep it in a cookie), then [read the profile](../get-profile/).
- Without `url`: the user sees this page, which also tries to close itself after a moment. Use it when you open the sign-in in a popup window. Your app then reads the profile with its session ID.

![The page that says You have logged in successfully and Close this page](/files/JapjQS2il61f.webp)

## Errors

| Status | Answer | Why |
|---|---|---|
| `400` | `[{"name":"serviceid","error":"The field \"serviceid\" is invalid",...}]` | `serviceid` or `sessionid` is missing. |
| `400` | `[{"error":"Service not found"}]` | No extension has that ID. |
| `401` | An HTML error page | The token is wrong or missing. |

See [Errors](../errors/) for the other addresses.
