---
title: Add a user
slug: opti-id/api/add-a-user
docTags: 
createdAt: 2026-10-01T19:58:50.958Z
---

{
  "id": "kYO2bp90SKwUhYt14M9qk",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://usermgmt-api.optimizely.com/api/users",
    "servers": [
      {
        "url": "https://usermgmt-api.optimizely.com/api/users"
      }
    ],
    "name": "Add a user",
    "description": "Add a user by passing the user's details.",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [
        {
          "name": "accept",
          "type": "string",
          "kind": "optional",
          "description": "Generated from available response content types",
          "enum": [
            "application/json"
          ],
          "default": "application/json"
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "description": "Details used to add a user.",
          "customType": "addUserParams",
          "schema": [
            {
              "name": "externalUserId",
              "kind": "optional",
              "type": "string",
              "nullable": true,
              "description": ""
            },
            {
              "name": "firstName",
              "kind": "required",
              "type": "string",
              "nullable": true,
              "description": "",
              "minLength": 1
            },
            {
              "name": "lastName",
              "kind": "required",
              "type": "string",
              "nullable": true,
              "description": "",
              "minLength": 1
            },
            {
              "name": "email",
              "kind": "required",
              "type": "string",
              "nullable": true,
              "description": "",
              "minLength": 1
            },
            {
              "name": "homeOrganizationId",
              "kind": "required",
              "type": "string",
              "nullable": true,
              "description": "",
              "minLength": 1
            },
            {
              "name": "userGroupIds",
              "kind": "optional",
              "type": "array",
              "nullable": true,
              "description": "",
              "example": "",
              "itemType": "string",
              "customType": "string[]",
              "itemExample": "",
              "itemDefault": ""
            },
            {
              "name": "properties",
              "kind": "optional",
              "type": "array",
              "nullable": true,
              "description": "",
              "modelRef": "#/components/schemas/property",
              "customType": "property[]",
              "schema": [
                {
                  "name": "name",
                  "kind": "optional",
                  "type": "string",
                  "nullable": true,
                  "description": ""
                },
                {
                  "name": "value",
                  "kind": "optional",
                  "type": "string",
                  "nullable": true,
                  "description": ""
                }
              ]
            },
            {
              "name": "isVirtual",
              "kind": "optional",
              "type": "boolean",
              "nullable": true,
              "description": ""
            }
          ],
          "modelRef": "#/components/schemas/addUserParams",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "oidc_auth",
          "name": "oidc_auth",
          "kind": "optional",
          "type": "oauth2",
          "oauth2Flows": {
            "authorizationCode": {
              "authorizationUrl": "https://login.optimizely.com/oauth2/default/v1/authorize",
              "tokenUrl": "https://login.optimizely.com/oauth2/default/v1/token",
              "scopes": {
                "openid": "Identifies the request as an OpenID Connect request (required)",
                "profile": "Requests access to the end user's default profile claims",
                "email": "Requests access to the email and email_verified claims",
                "offline_access": "Requests a refresh token used to obtain more access tokens without re-prompting the user for authentication",
                "idx_instancepermissions": "Request Instance Permissions claim for use with Optimizely Products"
              }
            }
          },
          "requiredScopes": [
            "openid",
            "profile",
            "email",
            "offline_access",
            "idx_instancepermissions"
          ]
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "The user response.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "user",
            "schema": [
              {
                "name": "id",
                "kind": "optional",
                "type": "string",
                "description": ""
              },
              {
                "name": "externalUserId",
                "kind": "optional",
                "type": "string",
                "description": ""
              },
              {
                "name": "firstName",
                "kind": "optional",
                "type": "string",
                "description": ""
              },
              {
                "name": "lastName",
                "kind": "optional",
                "type": "string",
                "description": ""
              },
              {
                "name": "email",
                "kind": "optional",
                "type": "string",
                "description": ""
              },
              {
                "name": "homeOrganizationId",
                "kind": "optional",
                "type": "string",
                "description": ""
              },
              {
                "name": "userGroupIds",
                "kind": "optional",
                "type": "array",
                "description": "",
                "example": "",
                "itemType": "string",
                "customType": "string[]",
                "itemExample": "",
                "itemDefault": ""
              },
              {
                "name": "lastLoggedIn",
                "kind": "optional",
                "type": "string<date-time>",
                "description": "",
                "format": "date-time"
              },
              {
                "name": "created",
                "kind": "optional",
                "type": "string<date-time>",
                "description": "",
                "format": "date-time"
              },
              {
                "name": "modified",
                "kind": "optional",
                "type": "string<date-time>",
                "description": "",
                "format": "date-time"
              },
              {
                "name": "properties",
                "kind": "optional",
                "type": "array",
                "description": "",
                "modelRef": "#/components/schemas/property",
                "customType": "property[]",
                "schema": [
                  {
                    "name": "name",
                    "kind": "optional",
                    "type": "string",
                    "nullable": true,
                    "description": ""
                  },
                  {
                    "name": "value",
                    "kind": "optional",
                    "type": "string",
                    "nullable": true,
                    "description": ""
                  }
                ]
              },
              {
                "name": "isLocalInSSO",
                "kind": "optional",
                "type": "boolean",
                "description": ""
              },
              {
                "name": "isVirtual",
                "kind": "optional",
                "type": "boolean",
                "description": ""
              },
              {
                "name": "links",
                "kind": "optional",
                "type": "array",
                "nullable": true,
                "description": "",
                "modelRef": "#/components/schemas/link",
                "customType": "link[]",
                "schema": [
                  {
                    "name": "rel",
                    "kind": "optional",
                    "type": "string",
                    "nullable": true,
                    "description": ""
                  },
                  {
                    "name": "href",
                    "kind": "optional",
                    "type": "string",
                    "nullable": true,
                    "description": ""
                  }
                ]
              }
            ],
            "modelRef": "#/components/schemas/user",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "The request was invalid or cannot be otherwise served. An accompanying error message will explain further.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "array",
            "description": "",
            "customType": "validationError[]",
            "schema": [
              {
                "name": "field",
                "kind": "optional",
                "type": "string",
                "nullable": true,
                "description": ""
              },
              {
                "name": "code",
                "kind": "optional",
                "type": "string",
                "nullable": true,
                "description": ""
              },
              {
                "name": "message",
                "kind": "optional",
                "type": "string",
                "nullable": true,
                "description": ""
              }
            ],
            "modelRef": "#/components/schemas/validationError",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "401",
        "description": "Unauthorized access to endpoint.",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "403",
        "description": "Forbidden access to endpoint.",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "500",
        "description": "<p>A server error occurred, please try again.</p>",
        "jsonExample": "",
        "isExpanded": true
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "ZNXzNEeYDlEGvdzl50XpY",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://usermgmt-api.optimizely.com/api/users \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"firstName\": \"\",\n     \"lastName\": \"\",\n     \"email\": \"\",\n     \"homeOrganizationId\": \"\"\n     }'"
        },
        {
          "id": "H-BRi1lrUK8y2ZFxX2Jy4",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"firstName\": \"\",\n   \"lastName\": \"\",\n   \"email\": \"\",\n   \"homeOrganizationId\": \"\"\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://usermgmt-api.optimizely.com/api/users\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "9xLNuA-USgzmMH42u1SKY",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://usermgmt-api.optimizely.com/api/users\")\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.body = JSON.dump({\n   \"firstName\": \"\",\n   \"lastName\": \"\",\n   \"email\": \"\",\n   \"homeOrganizationId\": \"\"\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "JGr96lWT0aF7oO-B9t951",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://usermgmt-api.optimizely.com/api/users\"\n\npayload = json.dumps({\n   \"firstName\": \"\",\n   \"lastName\": \"\",\n   \"email\": \"\",\n   \"homeOrganizationId\": \"\"\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "ZNXzNEeYDlEGvdzl50XpY"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// The user response.\n{\n  \"id\": \"\",\n  \"externalUserId\": \"\",\n  \"firstName\": \"\",\n  \"lastName\": \"\",\n  \"email\": \"\",\n  \"homeOrganizationId\": \"\",\n  \"userGroupIds\": [\n    \"\"\n  ],\n  \"lastLoggedIn\": \"\",\n  \"created\": \"\",\n  \"modified\": \"\",\n  \"properties\": [\n    {\n      \"name\": \"\",\n      \"value\": \"\"\n    }\n  ],\n  \"isLocalInSSO\": false,\n  \"isVirtual\": false,\n  \"links\": [\n    {\n      \"rel\": \"\",\n      \"href\": \"\"\n    }\n  ]\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// The request was invalid or cannot be otherwise served. An accompanying error message will explain further.\n[\n  {\n    \"field\": \"\",\n    \"code\": \"\",\n    \"message\": \"\"\n  }\n]"
        },
        {
          "id": "response-2-401",
          "language": "401",
          "code": "// Unauthorized access to endpoint.\n"
        },
        {
          "id": "response-3-403",
          "language": "403",
          "code": "// Forbidden access to endpoint.\n"
        },
        {
          "id": "response-4-500",
          "language": "500",
          "code": "// A server error occurred, please try again.\n"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}