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

# Create User

> Create new user for your organization

Create new user for your organization.

<Note>
  This endpoint creates a new user account and generates the necessary API
  credentials for accessing Credira services.
</Note>

## Authorizations

<ParamField header="Authorization" type="string" required>
  Add `Bearer YOUR_CREDIRA_AI_KEY` as the value of the `Authorization` header.
</ParamField>

## Body

<ParamField body="email" type="string" required>
  The email address for the new user account
</ParamField>

<ParamField body="name" type="string" required>
  The full name of the user
</ParamField>

<ParamField body="company" type="string" required>
  The company name associated with the user
</ParamField>

<ParamField body="role" type="string">
  The role of the user within the organization
</ParamField>

<ParamField body="department" type="string">
  The department the user belongs to
</ParamField>

<ParamField body="phone" type="string">
  The phone number of the user
</ParamField>

<ParamField body="metadata" type="object">
  Additional metadata for the user account
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
       --url https://api.credira.com/v1/users \
       --header 'Authorization: Bearer YOUR_CREDIRA_AI_KEY' \
       --header 'Content-Type: application/json' \
       --data '{
         "email": "john.doe@company.com",
         "name": "John Doe",
         "company": "Acme Corporation",
         "role": "billing_manager",
         "department": "finance",
         "phone": "+1234567890",
         "metadata": {
           "subscription_plan": "premium",
           "timezone": "America/New_York",
           "language": "en"
         }
       }'
  ```

  ```typescript TypeScript theme={null}
  const response = await fetch("https://api.credira.com/v1/users", {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_CREDIRA_AI_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      email: "john.doe@company.com",
      name: "John Doe",
      company: "Acme Corporation",
      role: "billing_manager",
      department: "finance",
      phone: "+1234567890",
      metadata: {
        subscription_plan: "premium",
        timezone: "America/New_York",
        language: "en",
      },
    }),
  });

  const data = await response.json();
  console.log(data);
  ```
</RequestExample>

<Banner type="info">
  **Status Codes:** 201 (Created), 400 (Bad Request), 401 (Unauthorized), 409
  (Conflict), 422 (Unprocessable Entity)
</Banner>

<ResponseExample status="201" summary="Created">
  ```json theme={null}
  {
    "success": true,
    "data": {
      "id": "user_123456789",
      "email": "john.doe@company.com",
      "name": "John Doe",
      "company": "Acme Corporation",
      "role": "billing_manager",
      "department": "finance",
      "phone": "+1234567890",
      "api_key": "credira_sk_1234567890abcdef",
      "account_id": "acc_789123456",
      "status": "active",
      "created_time": "2024-01-15T10:30:00Z",
      "last_login": null,
      "permissions": [
        "calls:read",
        "calls:write",
        "emails:read",
        "emails:write",
        "callouts:read",
        "callouts:write"
      ],
      "metadata": {
        "subscription_plan": "premium",
        "timezone": "America/New_York",
        "language": "en"
      }
    },
    "meta": {
      "timestamp": "2024-01-15T10:30:00Z",
      "request_id": "req_123456789",
      "message": "User created successfully"
    }
  }
  ```
</ResponseExample>

<ResponseExample status="400" summary="Bad Request">
  ```json theme={null}
  {
    "success": false,
    "error": {
      "code": "INVALID_REQUEST",
      "message": "Missing required field: email"
    },
    "meta": {
      "timestamp": "2024-01-15T10:30:00Z",
      "request_id": "req_123456789"
    }
  }
  ```
</ResponseExample>

<ResponseExample status="401" summary="Unauthorized">
  ```json theme={null}
  {
    "success": false,
    "error": {
      "code": "UNAUTHORIZED",
      "message": "Invalid or missing Credira AI key"
    },
    "meta": {
      "timestamp": "2024-01-15T10:30:00Z",
      "request_id": "req_123456789"
    }
  }
  ```
</ResponseExample>

<ResponseExample status="409" summary="Conflict">
  ```json theme={null}
  {
    "success": false,
    "error": {
      "code": "CONFLICT",
      "message": "User with this email already exists"
    },
    "meta": {
      "timestamp": "2024-01-15T10:30:00Z",
      "request_id": "req_123456789"
    }
  }
  ```
</ResponseExample>

<ResponseExample status="422" summary="Unprocessable Entity">
  ```json theme={null}
  {
    "success": false,
    "error": {
      "code": "VALIDATION_ERROR",
      "message": "Invalid email address format"
    },
    "meta": {
      "timestamp": "2024-01-15T10:30:00Z",
      "request_id": "req_123456789"
    }
  }
  ```
</ResponseExample>
