Users API

Overview of users API methods

post
Register User

https://api.codemash.io/:version/membership/users/register
Register a new user to a particular project.
Request
Response
Request
Path Parameters
version
required
string
A version of API endpoint.
Headers
Authorization
required
string
Secret API key which belongs to your project or user. Not required if using cookies with session ID.
x-cm-projectid
required
string
Your project's ID. Can be passed as query parameter.
Body Parameters
email
required
string
User's email address.
password
required
string
User's password.
displayName
optional
string
User's display name.
firstName
optional
string
User's first name.
lastName
optional
string
User's last name.
roles
optional
array
Roles to give to newly created user (don't provide any to use default role from settings).
autoLogin
optional
boolean
Should the user be logged in after registering. Default is true.
meta
optional
string
User's meta details as JSON object.
Response
200: OK
Returns user's authorization token and ID.
{
"result": true,
"apiKey": "{AUTHORIZATION_KEY}",
"userId": "{USER_ID_GUID}",
}
.NET
Node
.NET
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);
membershipService.RegisterUser(new RegisterUserRequest
{
Email = "test@email.com",
Password = "password123"
});
Node

Membership Settings

There are some settings for user registration inside your dashboard under sections Registration and Verification.

  • User registers as - if you don't provide roles during registration, user will be given selected role in the settings.

  • Verification by email needed - if this is checked, user will be unverified until verified through email. Email service needs to be enabled for this option. Also in your template you have to set a token named @Model.ValidationToken which will be replaced by verification token.

post
Invite User

https://api.codemash.io/:version/membership/users/invite
Invites user to a particular project.
Request
Response
Request
Path Parameters
version
required
string
A version of API endpoint.
Headers
Authorization
required
string
Secret API key which belongs to your project or user. Not required if using cookies with session ID.
x-cm-projectid
required
string
Your project's ID. Can be passed as query parameter.
Body Parameters
email
required
string
User's email address.
displayName
optional
string
User's display name.
firstName
optional
string
User's first name.
lastName
optional
string
User's last name.
roles
optional
array
Roles to give to newly created user (don't provide any to use default role from settings).
meta
optional
string
User's meta details as JSON object.
Response
200: OK
Returns user's ID.
{
"result": true,
"userId": "{USER_ID_GUID}"
}
.NET
Node
.NET
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);
membershipService.InviteUserAsync(new InviteUserRequest
{
Email = "test@email.com",
});
Node

Membership Settings

There are some settings for user invitation inside your dashboard under sections Registration and Invitation.

  • User registers as - if you don't provide roles during registration, user will be given selected role.

  • Allow invite users - this MUST be checked for invitations to work. Email service needs to be enabled for this option. Also in your template you have to set a token named @Model.ValidationToken which will be replaced by invitation token.

get
Get Users

https://api.codemash.io/:version/membership/users
Gets a list of project users.
Request
Response
Request
Path Parameters
version
required
string
A version of API endpoint.
Headers
Authorization
required
string
Secret API key which belongs to your project or user. Not required if using cookies with session ID.
x-cm-projectid
required
string
Your project's ID. Can be passed as query parameter.
Query Parameters
includePermissions
optional
boolean
Includes permissions to response.
includeDevices
optional
boolean
Includes devices to response.
includeMeta
optional
boolean
Includes meta to response.
Response
200: OK
Returns a list of users.
{
"totalCount": 20,
"result": [
{
"id": "{USER_ID}",
"email": "test@test.com"
...
},
...
]
}
.NET
Node
.NET
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);
var response = await membershipService.GetUsersListAsync(new GetUsersRequest());
Node

get
Get User

https://api.codemash.io/:version/membership/users/:id
Gets a project user.
Request
Response
Request
Path Parameters
version
required
string
A version of API endpoint.
id
required
string
User's ID.
Headers
Authorization
required
string
Secret API key which belongs to your project or user. Not required if using cookies with session ID.
x-cm-projectid
required
string
Your project's ID. Can be passed as query parameter.
Query Parameters
IncludeUnreadNotifications
optional
boolean
Includes unread push notifications count.
includePermissions
optional
boolean
Includes permissions to response.
includeDevices
optional
boolean
Includes devices to response.
includeMeta
optional
boolean
Includes meta to response.
Response
200: OK
Returns a list of users.
{
"totalCount": 20,
"result": [
{
"id": "{USER_ID}",
"email": "test@test.com"
...
},
...
]
}
.NET
Node
.NET
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);
var response = await membershipService.GetUserAsync(new GetUserRequest
{
Id = Guid.Parse("{USER_ID}")
});
Node

get
Get User (By Email)

https://api.codemash.io/:version/membership/users/by-email
Gets a project user by email.
Request
Response
Request
Path Parameters
version
required
string
A version of API endpoint.
Headers
Authorization
required
string
Secret API key which belongs to your project or user. Not required if using cookies with session ID.
x-cm-projectid
required
string
Your project's ID. Can be passed as query parameter.
Query Parameters
IncludeUnreadNotifications
optional
boolean
Includes unread push notifications count.
includePermissions
optional
boolean
Includes permissions to response.
includeDevices
optional
boolean
Includes devices to response.
includeMeta
optional
boolean
Includes meta to response.
Response
200: OK
Returns a list of users.
{
"totalCount": 20,
"result": [
{
"id": "{USER_ID}",
"email": "test@test.com"
...
},
...
]
}
.NET
.NET
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);
var response = await membershipService.GetUserAsync(new GetUserRequest
{
Email = "john.doe@email.com"
});

patch
Update profile

https://api.codemash.io/:version/membership/users/profile
Updates user's profile with given parameters. Only provided values are updated. This request does not update user roles.
Request
Response
Request
Path Parameters
version
required
string
A version of API endpoint.
Headers
Authorization
required
string
Secret API key which belongs to your project or user. Not required if using cookies with session ID.
x-cm-projectid
required
string
Your project's ID. Can be passed as query parameter.
Body Parameters
unsubscribedNewsTags
optional
array
Marketing email types to unsubscribe from. If value not provided then it's not updated. To delete, pass empty array.
subscribeToNews
optional
boolean
Should user receive marketing emails. If value not provided then it's not updated.
timeZone
optional
string
Default user's timezone.
language
optional
string
Default user's language (mainly for notifications).
displayName
optional
string
User's display name.
firstName
optional
string
User's first name.
lastName
optional
string
User's last name.
meta
optional
string
User's meta details as JSON.
Response
200: OK
Returns true if updated.
{
"result": true
}
.NET
.NET
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);
var response = await membershipService.UpdateUserAsync(new UpdateUserRequest
{
Id = Guid.Parse("{USER_ID}"),
DisplayName = "Updated Name"
});

patch
Update user

https://api.codemash.io/:version/membership/users/:id
Updates user with given parameters. Only provided values are updated. This request allows updating user roles.
Request
Response
Request
Path Parameters
version
required
string
A version of API endpoint.
id
required
string
User's ID.
Headers
Authorization
required
string
Secret API key which belongs to your project or user. Not required if using cookies with session ID.
x-cm-projectid
required
string
Your project's ID. Can be passed as query parameter.
Body Parameters
unsubscribedNewsTags
optional
array
Marketing email types to unsubscribe from. If value not provided then it's not updated. To delete, pass empty array.
subscribeToNews
optional
boolean
Should user receive marketing emails. If value not provided then it's not updated.
timeZone
optional
string
Default user's timezone.
language
optional
string
Default user's language (mainly for notifications).
displayName
optional
string
User's display name.
firstName
optional
string
User's first name.
lastName
optional
string
User's last name.
roles
optional
array
Roles to set for a user.
meta
optional
string
User's meta details as JSON.
Response
200: OK
Returns true if updated.
{
"result": true
}
.NET
Node
.NET
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);
var response = await membershipService.UpdateUserAsync(new UpdateUserRequest
{
Id = Guid.Parse("{USER_ID}"),
DisplayName = "Updated Name"
});
Node

delete
Delete user

https://api.codemash.io/:version/membership/users/:id
Deletes a project user.
Request
Response
Request
Path Parameters
version
required
string
A version of API endpoint.
id
required
string
User's ID.
Headers
Authorization
required
string
Secret API key which belongs to your project or user. Not required if using cookies with session ID.
x-cm-projectid
required
string
Your project's ID. Can be passed as query parameter.
Response
200: OK
Returns true if deleted.
{
"result": true
}
.NET
Node
.NET
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);
var reponse = await membershipService.DeleteUserAsync(new DeleteUserRequest
{
Id = Guid.Parse("{USER_ID}"),
});
Node

patch
Block user

https://api.codemash.io/:version/membership/users/:id/block
Blocks user from calling any authenticated requests.
Request
Response
Request
Path Parameters
version
required
string
A version of API endpoint.
id
required
string
User's ID.
Headers
Authorization
required
string
Secret API key which belongs to your project or user. Not required if using cookies with session ID.
x-cm-projectid
required
string
Your project's ID. Can be passed as query parameter.
Response
200: OK
Returns true if blocked.
{
"result": true
}
.NET
Node
.NET
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);
var reponse = await membershipService.DeleteUserAsync(new DeleteUserRequest
{
Id = Guid.Parse("{USER_ID}"),
});
Node

patch
Unblock user

https://api.codemash.io/:version/membership/users/:id/unblock
Unblocks user allowing to call authenticated calls.
Request
Response
Request
Path Parameters
version
required
string
A version of API endpoint.
id
required
string
User's ID.
Headers
Authorization
required
string
Secret API key which belongs to your project or user. Not required if using cookies with session ID.
x-cm-projectid
required
string
Your project's ID. Can be passed as query parameter.
Response
200: OK
Returns true if unblocked.
{
"result": true
}
.NET
Node
.NET
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);
var reponse = await membershipService.UnblockUserAsync(new UnblockUserRequest
{
Id = Guid.Parse("{USER_ID}"),
});
Node