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

# Get or Create User Group

<Info>
  The End User Group API is now deprecated and has been replaced by the Customer
  API. Each End User Group entity corresponds to a Customer entity, with its
  `user_group_id` corresponding to a Customer `customer_id`.

  This API method has been replaced by <a href="/api-reference/customer-api/get-or-create">Get or Create Customer</a>.
</Info>

This endpoint gets or creates a new user group. If the user\_group\_id does not exist, a new user group will be created and information about the group will be sent back. If the user\_group\_id exists, no action will be taken but the same information about the group will be sent back. There will be a flag in the response indicating if a new user group was created.

### Body

<ParamField body="name" type="string">
  This is the name of the user group.
</ParamField>

<ParamField body="user_group_id" type="string">
  This is the ID you use to identify this user group in your database.
</ParamField>

<ParamField body="mapping" type="object">
  This is a JSON mapping of schema id to either the data source that this user
  group should be associated with or id of the datasource you provided when
  creating it.
</ParamField>

<ParamField body="is_demo_group" type="boolean">
  Set this boolean parameter to true to make data panels include a demo
  watermark for the user group. Demo user groups do not count towards paid user
  groups. Default value is false.
</ParamField>

<ParamField body="properties" type="object">
  This is a JSON object for properties assigned to this user group. These will
  be accessible through variables in the dashboards and SQL editor
</ParamField>

### Response

<ResponseField name="success" type="number">
  Indicates whether the call was successful. 1 if successful, 0 if not.
</ResponseField>

<ResponseField name="new_user_group" type="boolean">
  Indicates whether a new user group was created.
</ResponseField>

<ResponseField name="user_group" type="object">
  The contents of the user group

  <Expandable title="Toggle object">
    <ResponseField name="team_id" type="number">
      This is Explo's internal ID for this user group. You don't need to record this
      information, since you will not need to use it.
    </ResponseField>

    <ResponseField name="token" type="string">
      This is the user group token (customerToken or CUSTOMER\_TOKEN) that will be
      used to identify which user group is viewing the dashboard. You should save
      this on your end to use when rendering an embedded dashboard.
    </ResponseField>

    <ResponseField name="name" type="string">
      This is the name of the user group provided in the request body.
    </ResponseField>

    <ResponseField name="provided_id" type="string">
      This is the user\_group\_id provided in the request body.
    </ResponseField>

    <ResponseField name="is_demo_group" type="boolean">
      If set to true, data panels displayed for the user group will include a demo
      watermark.
    </ResponseField>

    <ResponseField name="properties" type="JSON or null">
      This is the properties object if it was provided in the request body
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash Example Request theme={null}
  curl --location --request POST 'https://api.explo.co/api/create_user_group/' \
  --header 'Content-Type: application/json' \
  --header 'Explo-Authorization: Token <token>' \
  --data-raw '{
      "user_group_id": "example_1",
      "name": "Example 1",
      "mapping": {"40": "213", "134": "386"},
      "properties": {"filterValue": "value"}
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": 1,
    "new_user_group": true,
    "user_group": {
      "team_id": 3,
      "token": "<customer_token_to_auth_dashboard>",
      "name": "Example 1",
      "provided_id": "example_1",
      "is_demo_group": false
    }
  }
  ```
</ResponseExample>
