Create user

POST /api/users

Create a new user with the given data.

application/json

Body Required

  • primaryPhone string(regex)

    Primary phone number for the user. It should be unique across all users.

    Format should match the following pattern: /^\d+$/.

  • primaryEmail string(regex)

    Primary email address for the user. It should be unique across all users.

    Format should match the following pattern: /^\S+@\S+\.\S+$/.

  • username string(regex)

    Username for the user. It should be unique across all users.

    Format should match the following pattern: /^[A-Z_a-z]\w*$/.

  • password string

    Plain text password for the user.

    Minimum length is 1.

  • passwordDigest string

    In case you already have the password digests and not the passwords, you can use them for the newly created user via this property. The value should be generated with one of the supported algorithms. The algorithm can be specified using the passwordAlgorithm property.

  • passwordAlgorithm string

    The hash algorithm used for the password. It should be one of the supported algorithms: argon2, md5, sha1, sha256. Should the encryption algorithm differ from argon2, it will automatically be upgraded to argon2 upon the user's next sign-in.

    Values are Argon2i, Argon2id, Argon2d, SHA1, SHA256, MD5, or Bcrypt.

  • name string
  • avatar string(url) | null | string(empty)

  • customData object

    arbitrary

  • profile object
    Hide profile attributes Show profile attributes object
    • familyName string
    • givenName string
    • middleName string
    • nickname string
    • preferredUsername string
    • profile string
    • website string
    • gender string
    • birthdate string
    • zoneinfo string
    • locale string
    • address object
      Hide address attributes Show address attributes object
      • formatted string
      • streetAddress string
      • locality string
      • region string
      • postalCode string
      • country string

Responses

  • 200 application/json

    User data for the newly created user.

    Hide response attributes Show response attributes object
    • id string Required

      Minimum length is 1, maximum length is 12.

    • username string | null Required

      Maximum length is 128.

    • primaryEmail string | null Required

      Maximum length is 128.

    • primaryPhone string | null Required

      Maximum length is 128.

    • name string | null Required

      Maximum length is 128.

    • avatar string | null Required

      Maximum length is 2048.

    • customData object Required

      arbitrary

    • identities object Required
      Hide identities attributes Show identities attributes object
      • Additional properties
      • userId string Required
      • details object

        arbitrary

    • lastSignInAt number | null Required
    • createdAt number Required
    • updatedAt number Required
    • profile object Required
      Hide profile attributes Show profile attributes object
      • familyName string
      • givenName string
      • middleName string
      • nickname string
      • preferredUsername string
      • profile string
      • website string
      • gender string
      • birthdate string
      • zoneinfo string
      • locale string
      • address object
        Hide address attributes Show address attributes object
        • formatted string
        • streetAddress string
        • locality string
        • region string
        • postalCode string
        • country string
    • applicationId string | null Required

      Maximum length is 21.

    • isSuspended boolean Required
    • hasPassword boolean
    • ssoIdentities array[object]
      Hide ssoIdentities attributes Show ssoIdentities attributes object
      • tenantId string Required

        Maximum length is 21.

      • id string Required

        Minimum length is 1, maximum length is 21.

      • userId string Required

        Minimum length is 1, maximum length is 12.

      • issuer string Required

        Minimum length is 1, maximum length is 256.

      • identityId string Required

        Minimum length is 1, maximum length is 128.

      • detail object Required

        arbitrary

      • createdAt number Required
      • ssoConnectorId string Required

        Minimum length is 1, maximum length is 128.

  • 400

    Bad Request

  • 401

    Unauthorized

  • 403

    Forbidden

  • 404

    Not Found

  • 422

    Unprocessable Content

POST /api/users
curl \
 --request POST 'https://[tenant_id].logto.app/api/users' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{"primaryPhone":"string","primaryEmail":"string","username":"string","password":"string","passwordDigest":"string","passwordAlgorithm":"Argon2i","name":"string","avatar":"string","customData":{},"profile":{"familyName":"string","givenName":"string","middleName":"string","nickname":"string","preferredUsername":"string","profile":"string","website":"string","gender":"string","birthdate":"string","zoneinfo":"string","locale":"string","address":{"formatted":"string","streetAddress":"string","locality":"string","region":"string","postalCode":"string","country":"string"}}}'
Request examples
{
  "primaryPhone": "string",
  "primaryEmail": "string",
  "username": "string",
  "password": "string",
  "passwordDigest": "string",
  "passwordAlgorithm": "Argon2i",
  "name": "string",
  "avatar": "string",
  "customData": {},
  "profile": {
    "familyName": "string",
    "givenName": "string",
    "middleName": "string",
    "nickname": "string",
    "preferredUsername": "string",
    "profile": "string",
    "website": "string",
    "gender": "string",
    "birthdate": "string",
    "zoneinfo": "string",
    "locale": "string",
    "address": {
      "formatted": "string",
      "streetAddress": "string",
      "locality": "string",
      "region": "string",
      "postalCode": "string",
      "country": "string"
    }
  }
}
Response examples (200)
{
  "id": "string",
  "username": "string",
  "primaryEmail": "string",
  "primaryPhone": "string",
  "name": "string",
  "avatar": "string",
  "customData": {},
  "identities": {
    "userId": "string",
    "details": {}
  },
  "lastSignInAt": 42.0,
  "createdAt": 42.0,
  "updatedAt": 42.0,
  "profile": {
    "familyName": "string",
    "givenName": "string",
    "middleName": "string",
    "nickname": "string",
    "preferredUsername": "string",
    "profile": "string",
    "website": "string",
    "gender": "string",
    "birthdate": "string",
    "zoneinfo": "string",
    "locale": "string",
    "address": {
      "formatted": "string",
      "streetAddress": "string",
      "locality": "string",
      "region": "string",
      "postalCode": "string",
      "country": "string"
    }
  },
  "applicationId": "string",
  "isSuspended": true,
  "hasPassword": true,
  "ssoIdentities": [
    {
      "tenantId": "string",
      "id": "string",
      "userId": "string",
      "issuer": "string",
      "identityId": "string",
      "detail": {},
      "createdAt": 42.0,
      "ssoConnectorId": "string"
    }
  ]
}