---
title: Ensure a CometChat user for the pet parent and return a login token
slug: ensure-a-cometchat-user-for-the-pet-parent-and-return-a-login-token
createdAt: 2026-12-03T15:33:43.115Z
---

{
  "id": "WMj6EyWxQYfTkUiBEw7U5",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://developer.digitail.io/api/v1/for-pet-parents/chat-users/{chatUser}/comet-chat",
    "servers": [
      {
        "url": "https://developer.digitail.io/api/v1/for-pet-parents/chat-users/{chatUser}/comet-chat",
        "description": "Sandbox server (uses test data)"
      },
      {
        "url": "https://vet.digitail.io/api/v1/for-pet-parents/chat-users/{chatUser}/comet-chat",
        "description": "Production server (uses live data)"
      }
    ],
    "name": "Ensure a CometChat user for the pet parent and return a login token",
    "description": "<p>Requires an authenticated pet parent who is a client of the clinic. Creates the CometChat user for an existing chat uid when it is missing, and does nothing when it already exists. The uid must be the caller's own chat user, or the chat user of a clinic the caller belongs to. The clinic is the <code>X-ClinicId</code> header and selects the CometChat tenant. Returns a CometChat auth token only for the caller's own uid. A clinic uid is ensured without a token. Mobile clients that previously called <code>POST /for-pet-parents/chat/login-token</code> must use this endpoint instead and read <code>auth_token</code> from the response when ensuring their own uid. The caller's own token is issued once and reused; the auth key is not returned.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "chatUser",
          "type": "string",
          "description": "Chat user uid."
        }
      ],
      "headerParameters": [
        {
          "name": "accept",
          "type": "string",
          "kind": "optional",
          "description": "Generated from available response content types",
          "enum": [
            "application/json"
          ],
          "default": "application/json"
        },
        {
          "kind": "required",
          "name": "X-ClinicId",
          "type": "integer",
          "example": 605,
          "description": "Id of the clinic whose CometChat tenant should own the user."
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "passport",
          "name": "passport",
          "kind": "optional",
          "type": "oauth2",
          "description": "Laravel passport oauth2 security.",
          "oauth2Flows": {
            "authorizationCode": {
              "authorizationUrl": "http://localhost:8080/oauth/authorize",
              "tokenUrl": "http://localhost:8080/oauth/token",
              "refreshUrl": "http://localhost:8080/oauth/token"
            }
          }
        },
        {
          "id": "Bearer",
          "name": "Bearer",
          "kind": "optional",
          "type": "http",
          "scheme": "bearer"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "201",
        "description": "Caller's CometChat user is present and a login token is available.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "schema": [
              {
                "name": "data",
                "kind": "required",
                "type": "object",
                "description": "",
                "example": "",
                "schema": [
                  {
                    "name": "auth_token",
                    "kind": "required",
                    "type": "string",
                    "description": ""
                  }
                ]
              }
            ],
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "example-0-curl",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://developer.digitail.io/api/v1/for-pet-parents/chat-users/{chatUser}/comet-chat \\\n     --header 'accept: application/json' \\\n     --header 'x-clinicid: 605'"
        },
        {
          "id": "example-1-javascript",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\nmyHeaders.append(\"x-clinicid\", \"605\");\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://developer.digitail.io/api/v1/for-pet-parents/chat-users/{chatUser}/comet-chat\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "example-2-ruby",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://developer.digitail.io/api/v1/for-pet-parents/chat-users/{chatUser}/comet-chat\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest[\"x-clinicid\"] = \"605\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "example-3-python",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://developer.digitail.io/api/v1/for-pet-parents/chat-users/{chatUser}/comet-chat\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json',\n   'x-clinicid': '605'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "example-0-curl"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-201",
          "language": "201",
          "code": "// Caller's CometChat user is present and a login token is available.\n{\n  \"data\": {\n    \"auth_token\": \"\"\n  }\n}"
        }
      ],
      "selectedLanguageId": "response-0-201"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}