# Users | Signal House API Docs

> Create, update and remove users, and manage their roles and profiles, with the Signal House API.

Source: https://docs.signalhouse.io/users

---

## Users

### GET /user

Retrieve user records. Customer roles must pass at least one filter (id or groupId) — an unfiltered read-all is restricted to internal use. Note: the 'developer' role is restricted to service-user queries only; it must supply both groupId and userType=service. Any other combination (no groupId, userType=user, or groupId without userType=service) returns 403 for the developer role. Each user includes a read-only lastLoginAt: the time of the user's most recent portal login, or null if they have not logged in since it began being recorded. It cannot be set through PUT /user/:id. The groupIds, subgroupIds and status query parameters belong to the internal unfiltered list; sending any of them with id, email or groupId returns 400.

**The following roles are required to use this endpoint:** `admin`, `developer`, `api`, `self`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | Query Param | Optional | Specific User ObjectId. |
| `groupId` | Query Param | Optional | Filter by Group ID. |
| `userType` | Query Param | Optional | Filter by type: 'user' or 'service'. The 'developer' role requires userType=service. |

#### Example Response 200

Response

```json
[
  {
    "_id": "60f7b2a1c9e77c001a2b3c61",
    "role": "admin",
    "status": "active",
    "mfaEnabled": false,
    "viewGroupIds": [
      "G1234567"
    ],
    "activeGroupId": "G1234567",
    "email": "user@example.com",
    "firstName": "John",
    "lastName": "Doe",
    "companyName": "Acme Corp",
    "phone": "5551234567",
    "timezone": "America/Chicago",
    "lastLoginAt": "2024-01-15T13:30:00.000Z",
    "createdAt": "2024-01-15T12:00:00.000Z",
    "updatedAt": "2024-01-15T12:00:00.000Z"
  }
]
```

### POST /user

Create a new dashboard user.

**The following roles are required to use this endpoint:** `admin`, `api`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | String | Required | Group ID. |
| `role` | String | Required | The role to assign. Accepted values: admin, developer, billing, user. |
| `email` | String | Required | User email. |
| `password` | String | Required | Password. |
| `firstName` | String | Optional | User's first name. |
| `lastName` | String | Optional | User's last name. |
| `companyName` | String | Optional | User's company name. |
| `phone` | String | Optional | User's phone number. |
| `profileImageLink` | String | Optional | URL to the user's profile image. |
| `addressLine1` | String | Optional | Primary street address. |
| `addressLine2` | String | Optional | Secondary street address (suite, apt, etc.). |
| `city` | String | Optional | City. |
| `state` | String | Optional | State or province. |
| `country` | String | Optional | Country. |
| `postalCode` | String | Optional | Postal or ZIP code. |
| `signupSource` | String | Optional | Where the user signed up from (e.g., web, api, referral). |
| `timezone` | String | Optional | User's timezone. |
| `acceptedTermsOfService` | Boolean | Optional | Whether the user has accepted the Terms of Service. |

#### Example Request

Request

```json
{
  "groupId": "G1234567",
  "role": "admin",
  "email": "user@example.com",
  "password": "securepassword123"
}
```

#### Example Response 201

Response

```json
{
  "user": {
    "_id": "60f7b2a1c9e77c001a2b3c61",
    "role": "admin",
    "status": "active",
    "activeGroupId": "G1234567",
    "email": "user@example.com",
    "createdAt": "2024-01-15T12:00:00.000Z",
    "updatedAt": "2024-01-15T12:00:00.000Z"
  }
}
```

### PUT /user/accept-terms

Accept the Terms of Service for the authenticated caller. Sets acceptedTermsOfService=true on the caller's own user account. Self-service — any authenticated user can accept their own terms.

**The following roles are required to use this endpoint:** `admin`, `developer`, `billing`, `user`, `api`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `acceptedTermsOfService` | Boolean | Required | Must be true. |

#### Example Request

Request

```json
{
  "acceptedTermsOfService": true
}
```

#### Example Response 200

Response

```json
{
  "acceptedTermsOfService": true
}
```

### POST /user/serviceuser

Create a non-login Service User (API Key) and instantly returns a JWT.

**The following roles are required to use this endpoint:** `admin`, `developer`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | String | Optional | Group ID the service user belongs to (starts with G, exactly 8 chars). Required when role is 'api'; omit for 'signalhouse\_api'. |
| `name` | String | Required | Friendly name for the service key. |
| `role` | String | Required | Must be 'api' (or 'signalhouse\_api' for internal accounts). |
| `allowedIps` | Array<String> | Optional | Only accept this key from these IPv4/IPv6 addresses or CIDR ranges, e.g. \["203.0.113.10", "198.51.100.0/24"\]. Max 100. Omit or \[\] for no IP restriction. 'api' keys only. |
| `allowedCountries` | Array<String> | Optional | Only accept this key from these countries (ISO 3166-1 alpha-2, e.g. \["US", "CA"\]). Must be an assigned code: "UK" is rejected (use "GB"), as is "ZZ". Max 250. Omit or \[\] for no country restriction. When both lists are set, a request must match both. 'api' keys only. |
| `allowedDestinationCountries` | Array<String> | Optional | Only let this key send messages to these countries (ISO 3166-1 alpha-2, e.g. \["US", "CA"\]). A send with any recipient elsewhere is rejected with 403 DESTINATION\_COUNTRY\_NOT\_ALLOWED and nothing goes out. US toll-free numbers count as US; Guernsey (GG), Jersey (JE) and the Isle of Man (IM) are separate from GB. Max 250. Omit or \[\] for any country. 'api' keys only. |

#### Example Request

Request

```json
{
  "groupId": "G1234567",
  "name": "Backend Integration",
  "role": "api"
}
```

#### Example Response 201

Response

```json
{
  "user": {
    "user": {
      "_id": "60f7b2a1c9e77c001a2b3c62",
      "role": "api",
      "status": "active",
      "activeGroupId": "G1234567",
      "viewGroupIds": [
        "G1234567"
      ],
      "firstName": "Backend Integration",
      "mfaEnabled": false,
      "createdAt": "2024-01-15T12:00:00.000Z",
      "updatedAt": "2024-01-15T12:00:00.000Z"
    },
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2MGY3YjJhMWM5ZTc3YzAwMWEyYjNjNjIiLCJncm91cElkIjoiRzEyMzQ1NjciLCJyb2xlIjoiYXBpIiwiaWF0IjoxNjkwMDAwMDAwLCJleHAiOjE3MjE1MzYwMDB9.placeholder_signature"
  }
}
```

### PUT /user/:id

Update an existing user's details.

**The following roles are required to use this endpoint:** `admin`, `api`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | URL Param | Required | User ObjectId. |
| `role` | String | Optional | The role to assign. Accepted values: admin, developer, billing, user. |
| `status` | String | Optional | User status. Accepted values: active, inactive. |
| `email` | String | Optional | User email. |
| `firstName` | String | Optional | First name. |
| `lastName` | String | Optional | Last name. |
| `companyName` | String | Optional | Company name. |
| `phone` | String | Optional | Phone number. |
| `profileImageLink` | String | Optional | URL to the user profile image. |
| `addressLine1` | String | Optional | Street address line 1. |
| `addressLine2` | String | Optional | Street address line 2. |
| `city` | String | Optional | City. |
| `state` | String | Optional | State or province. |
| `country` | String | Optional | Country. |
| `postalCode` | String | Optional | Postal or ZIP code. |
| `timezone` | String | Optional | Timezone. |
| `allowedIps` | Array<String> | Optional | API keys only: replaces the key's allowed IPv4/IPv6 addresses or CIDR ranges (\[\] removes the restriction). Requires a portal login with the admin or developer role; an API key cannot change its own restrictions. Service users accept only status, allowedIps, allowedCountries and allowedDestinationCountries. |
| `allowedCountries` | Array<String> | Optional | API keys only: replaces the key's allowed ISO 3166-1 alpha-2 country codes (\[\] removes the restriction). Unassigned codes such as "UK" (use "GB") are rejected with 400. Same permission rules as allowedIps. |
| `allowedDestinationCountries` | Array<String> | Optional | API keys only: replaces the countries the key may send messages to (\[\] allows any country). Same validation and permission rules as allowedCountries. |

#### Example Response 200

Response

```json
{
  "user": {
    "_id": "60f7b2a1c9e77c001a2b3c61",
    "role": "admin",
    "status": "active",
    "email": "user@example.com",
    "firstName": "John",
    "lastName": "Doe Updated",
    "updatedAt": "2024-01-16T14:00:00.000Z"
  }
}
```

### DELETE /user/:id

Inactivate a user, revoking their login access.

**The following roles are required to use this endpoint:** `admin`, `api`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | URL Param | Required | User ObjectId. |

#### Example Response 200

Response

```json
{
  "message": "User inactivated successfully"
}
```

### GET /user/:id/notification-preferences

Retrieve notification preferences for a user.

**The following roles are required to use this endpoint:** `admin`, `api`, `self`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | URL Param | Required | User ObjectId. |

#### Example Response 200

Response

```json
[
  {
    "name": "BRAND_CREATION_SUCCESSFUL",
    "web": true,
    "email": true
  },
  {
    "name": "BRAND_CREATION_FAILED",
    "web": true,
    "email": false
  },
  {
    "name": "CAMPAIGN_APPROVED_BY_SIGNAL_HOUSE",
    "web": true,
    "email": false
  },
  {
    "name": "MESSAGE_DELIVERY_FAILURE",
    "web": true,
    "email": true
  }
]
```

### PUT /user/:id/notification-preferences

Update notification preferences for a user. Restricted to human dashboard users (admin, developer, billing, user) — service (api) users and internal accounts are not eligible and will receive a 403.

**The following roles are required to use this endpoint:** `admin`, `developer`, `billing`, `user`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | URL Param | Required | User ObjectId. |
| `notificationPreferences` | Array\[Object\] | Required | Array of preference objects. Duplicate names are not allowed. |
| `notificationPreferences[].name` | String | Required | Preference identifier (e.g., BRAND\_CREATION\_FAILED). |
| `notificationPreferences[].web` | Boolean | Required | Enable/disable web notifications. |
| `notificationPreferences[].email` | Boolean | Required | Enable/disable email notifications. |

#### Example Request

Request

```json
{
  "notificationPreferences": [
    {
      "name": "BRAND_CREATION_SUCCESSFUL",
      "web": true,
      "email": true
    },
    {
      "name": "CAMPAIGN_APPROVED_BY_SIGNAL_HOUSE",
      "web": true,
      "email": false
    }
  ]
}
```

#### Example Response 200

Response

```json
{
  "notificationPreferences": [
    {
      "name": "BRAND_CREATION_SUCCESSFUL",
      "web": true,
      "email": true
    },
    {
      "name": "CAMPAIGN_APPROVED_BY_SIGNAL_HOUSE",
      "web": true,
      "email": false
    }
  ]
}
```
