CRM User Operations
This document provides detailed information about the GraphQL operations available for managing CRM users. All operations require authentication and are restricted to users with the OWNER role.
Queries​
crmUser​
Retrieves a specific CRM user by ID.
query crmUser($id: ID!) {
crmUser(id: $id) {
_id
email
name
role
jobTitle
isLocked
isInactive
createdAt
updatedAt
}
}
Variables:
{
"id": "60d21b4667d0d8992e610c85"
}
Response:
{
"data": {
"crmUser": {
"_id": "60d21b4667d0d8992e610c85",
"email": "admin@example.com",
"name": "Admin User",
"role": "OWNER",
"jobTitle": "System Administrator",
"isLocked": false,
"isInactive": false,
"createdAt": "2023-04-12T10:30:00Z",
"updatedAt": "2023-04-12T10:30:00Z"
}
}
}
crmUsers​
Retrieves a paginated list of CRM users with filtering and sorting options.
query crmUsers(
$limit: Int!
$offset: Int!
$order: OrderDirection
$orderBy: String
$filter: CrmUsersFilterInput
) {
crmUsers(
limit: $limit
offset: $offset
order: $order
orderBy: $orderBy
filter: $filter
) {
count
limit
offset
data {
_id
email
name
role
jobTitle
isLocked
isInactive
createdAt
updatedAt
}
}
}
Variables:
{
"limit": 10,
"offset": 0,
"order": "DESC",
"orderBy": "createdAt",
"filter": {
"role": "OWNER",
"isInactive": false
}
}
Response:
{
"data": {
"crmUsers": {
"count": 2,
"limit": 10,
"offset": 0,
"data": [
{
"_id": "60d21b4667d0d8992e610c85",
"email": "admin@example.com",
"name": "Admin User",
"role": "OWNER",
"jobTitle": "System Administrator",
"isLocked": false,
"isInactive": false,
"createdAt": "2023-04-12T10:30:00Z",
"updatedAt": "2023-04-12T10:30:00Z"
},
{
"_id": "60d21b4667d0d8992e610c86",
"email": "owner@example.com",
"name": "Owner User",
"role": "OWNER",
"jobTitle": "Platform Owner",
"isLocked": false,
"isInactive": false,
"createdAt": "2023-04-11T09:15:00Z",
"updatedAt": "2023-04-11T09:15:00Z"
}
]
}
}
}
Mutations​
createUpdateCrmUser​
Creates a new CRM user or updates an existing one.
mutation createUpdateCrmUser($input: CreateUpdateCrmUserInput!) {
createUpdateCrmUser(input: $input) {
_id
email
name
role
jobTitle
isLocked
isInactive
createdAt
updatedAt
}
}
Variables for Create:
{
"input": {
"email": "newuser@example.com",
"name": "New User",
"role": "ADMIN",
"jobTitle": "Content Manager",
"isInactive": false
}
}
Variables for Update:
{
"input": {
"id": "60d21b4667d0d8992e610c85",
"email": "updateduser@example.com",
"name": "Updated User",
"role": "ADMIN",
"jobTitle": "Senior Content Manager"
}
}
Response:
{
"data": {
"createUpdateCrmUser": {
"_id": "60d21b4667d0d8992e610c85",
"email": "updateduser@example.com",
"name": "Updated User",
"role": "ADMIN",
"jobTitle": "Senior Content Manager",
"isLocked": false,
"isInactive": false,
"createdAt": "2023-04-12T10:30:00Z",
"updatedAt": "2023-04-13T15:45:00Z"
}
}
}
unlockCrmUser​
Unlocks a CRM user who has been locked due to failed login attempts.
mutation unlockCrmUser($input: UnlockCrmUserInput!) {
unlockCrmUser(input: $input)
}
Variables:
{
"input": {
"crmUserId": "60d21b4667d0d8992e610c85"
}
}
Response:
{
"data": {
"unlockCrmUser": true
}
}
deleteCrmUsers​
Deletes one or more CRM users by their IDs.
mutation deleteCrmUsers($ids: [ID!]!) {
deleteCrmUsers(ids: $ids)
}
Variables:
{
"ids": ["60d21b4667d0d8992e610c85", "60d21b4667d0d8992e610c86"]
}
Response:
{
"data": {
"deleteCrmUsers": true
}
}
Error Handling​
When an operation fails, the API returns an error object with a message. Here are some common error scenarios:
User Not Found​
{
"errors": [
{
"message": "NOT_FOUND",
"path": ["crmUser"]
}
],
"data": null
}
Update Failed​
{
"errors": [
{
"message": "UPDATE_FAILED",
"path": ["createUpdateCrmUser"]
}
],
"data": null
}
Self-Unlock Attempt​
{
"errors": [
{
"message": "Users cannot unlock themselves",
"path": ["unlockCrmUser"]
}
],
"data": null
}
Filter Options​
The CRM Users query supports various filter options:
- ids: Filter by array of user IDs
- email: Filter by email (partial match)
- name: Filter by name (partial match)
- role: Filter by role (exact match)
- isLocked: Filter by lock status
- isInactive: Filter by active status
- withDeleted: Include soft-deleted users