> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chatsyncs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Direct Login URL

> Generate a secure one-time login URL for a ChatSyncs user via the API, creating the user if they don't exist. Use when a developer asks how to build single sign-on into ChatSyncs from their own platform.

Generates a unique, secure one-time login URL for a **ChatSyncs end-user account** — useful for
single sign-on from your own platform into ChatSyncs. This is "get-or-create": if the email
already exists under your agent, it just returns a login link for that account; if it doesn't
exist yet, it creates it first (when you pass `create_on_fail=1`, `package_id`, and
`expired_date`).

<Tip>
  **Where to find `package_id`** (only needed when creating a new user): open **Control Panel →
  User Permission** — it's the **Package ID** column. See
  [Finding Your IDs & API Token](/developer-api/finding-ids#package-id-package_id) for a
  screenshot.
</Tip>

## What happens for each kind of email

| Situation                                         | Result                                                                                                                      |
| ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| Email doesn't exist anywhere yet                  | Creates it (needs `create_on_fail=1` + `package_id` + `expired_date`), returns a login link                                 |
| Email already exists, **under your own agent**    | Returns a login link for that existing account — no error                                                                   |
| Email already exists, **under a different agent** | `{"status":"0","message":"User is already registered under another agent."}`                                                |
| **Your own agent/owner email**                    | Same error as above — your account isn't a sub-user created via this API, so this endpoint can never generate a link for it |

<Warning>
  **This endpoint is only for end-user accounts your agent manages — never for your own agent
  login.** Confirmed by testing: a brand-new email works cleanly and returns a real login link.
  Your own ChatSyncs login email will always fail with `"User is already registered under
    another agent."` — that's expected, not a bug. To log into your own account, just use your
  normal password at platform.chatsyncs.com; this API has no use for that.
</Warning>

## Get Direct Login URL vs. New Users Only

|                                         | Get Direct Login URL                                               | Get Direct Login URL (New Users Only)                                                 |
| --------------------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------- |
| Email is new                            | Creates the account, returns a login link                          | Creates the account, returns a login link                                             |
| Email already exists (under your agent) | Returns a login link — **no error**                                | Fails — `"User already existed"`                                                      |
| Use it for                              | Any normal "log in" button — works for new and returning customers | **Sign-up forms only** — guarantees you never log into an existing account by mistake |


## OpenAPI

````yaml GET /user/get/direct-login-url
openapi: 3.1.0
info:
  title: ChatSyncs Developer API
  version: 1.0.0
  description: >-
    REST API for sending WhatsApp messages and managing subscribers through
    ChatSyncs.
servers:
  - url: https://platform.chatsyncs.com/api/v1
security: []
paths:
  /user/get/direct-login-url:
    get:
      tags:
        - User API
      summary: Get Direct Login URL
      operationId: directLoginUrl
      parameters:
        - name: apiToken
          in: query
          required: true
          schema:
            type: string
            example: API-KEY
          description: >-
            Your ChatSyncs API key (not a WhatsApp/Meta access token). [Where to
            find it](/developer-api/finding-ids#api-token-apitoken).
        - name: email
          in: query
          required: true
          schema:
            type: string
            example: user@example.com
          description: The user's email.
        - name: name
          in: query
          required: false
          schema:
            type: string
          description: The user's name.
        - name: mobile
          in: query
          required: false
          schema:
            type: string
          description: The user's phone number.
        - name: package_id
          in: query
          required: false
          schema:
            type: integer
          description: >-
            The package ID to assign. Required when creating a new user. [Where
            to find it](/developer-api/finding-ids#package-id-package_id).
        - name: expired_date
          in: query
          required: false
          schema:
            type: string
          description: >-
            Package expiry date, e.g. 2026-05-05. Required when creating a new
            user.
        - name: status
          in: query
          required: false
          schema:
            type: string
          description: User status — active (1) or inactive (0).
        - name: create_on_fail
          in: query
          required: false
          schema:
            type: string
          description: >-
            Set to 1 to create a new user if none is found, or 0 to return a
            'User not found' error.
      responses:
        '200':
          description: >-
            On success, `message` is an **object** with `email`, `password`,
            `login_url`, and `direct_login_url` — not a plain string.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    description: '`"1"` = success, `"0"` = failure.'
                  message:
                    description: >-
                      On success: an object with `email`, `password`,
                      `login_url`, `direct_login_url`. On failure: a plain error
                      string.
              examples:
                success:
                  summary: Success
                  value:
                    status: '1'
                    message:
                      email: user@domain.com
                      password: xxxxxxxxxx
                      login_url: https://platform.chatsyncs.com/login
                      direct_login_url: https://platform.chatsyncs.com/direct-login/xxxxxxxxxx
                error:
                  summary: Error — registered under another agent
                  value:
                    status: '0'
                    message: User is already registered under another agent.

````