Users

Overview of users API methods

Register User

POST https://api.codemash.io/:version/membership/users/register

Register a new user to a particular project.

Path Parameters

NameTypeDescription

version

string

A version of the API endpoint.

Headers

NameTypeDescription

Authorization

string

Secret API key which belongs to your project or user. Not required if using cookies with a session ID.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

Request Body

NameTypeDescription

email

string

User's email address.

password

string

User's password.

displayName

string

User's display name.

firstName

string

User's first name.

lastName

string

User's last name.

roles

array

Roles to give to the newly created user (don't provide any to use default role from settings).

autoLogin

boolean

Should the user be logged in after registering? The default is true.

meta

string

User's meta details as a JSON object.

{
    "result": true,
    "apiKey": "{AUTHORIZATION_KEY}",
    "userId": "{USER_ID_GUID}",
}
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);

membershipService.RegisterUser(new RegisterUserRequest
{
    Email = "test@email.com",
    Password = "password123"
});

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, the user will be given a selected role in the settings.

  • Verification by email needed - if this is checked, the 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 a verification token.

Invite User

POST https://api.codemash.io/:version/membership/users/invite

Invites an user to a particular project.

Path Parameters

NameTypeDescription

version

string

A version of the API endpoint.

Headers

NameTypeDescription

Authorization

string

Secret API key which belongs to your project or user. Not required if using cookies with a session ID.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

Request Body

NameTypeDescription

email

string

User's email address.

displayName

string

User's display name.

firstName

string

User's first name.

lastName

string

User's last name.

roles

array

Roles to give to the newly created user (don't provide any to use default role from settings).

meta

string

User's meta details as a JSON object.

{
    "result": true,
    "userId": "{USER_ID_GUID}"
}
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);

membershipService.InviteUserAsync(new InviteUserRequest
{
    Email = "test@email.com",
});

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, the user will be given a 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 an invitation token.

Get Users

GET https://api.codemash.io/:version/membership/users

Gets a list of project users.

Path Parameters

NameTypeDescription

version

string

A version of the API endpoint.

Query Parameters

NameTypeDescription

includePermissions

boolean

Includes permissions to the response.

includeDevices

boolean

Includes devices to the response.

includeMeta

boolean

Includes meta to the response.

Headers

NameTypeDescription

Authorization

string

Secret API key which belongs to your project or user. Not required if using cookies with a session ID.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

{
    "totalCount": 20,
    "result": [
        {
            "id": "{USER_ID}",
            "email": "test@test.com"
            ...
        },
        ...
    ]
}
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);

var response = await membershipService.GetUsersListAsync(new GetUsersRequest());

Get User

GET https://api.codemash.io/:version/membership/users/:id

Gets a project user.

Path Parameters

NameTypeDescription

version

string

A version of the API endpoint.

id

string

User's ID.

Query Parameters

NameTypeDescription

IncludeUnreadNotifications

boolean

Includes unread push notifications count.

includePermissions

boolean

Includes permissions to the response.

includeDevices

boolean

Includes devices to the response.

includeMeta

boolean

Includes meta to the response.

Headers

NameTypeDescription

Authorization

string

Secret API key which belongs to your project or user. Not required if using cookies with a session ID.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

{
    "totalCount": 20,
    "result": [
        {
            "id": "{USER_ID}",
            "email": "test@test.com"
            ...
        },
        ...
    ]
}
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);

var response = await membershipService.GetUserAsync(new GetUserRequest
{
    Id = Guid.Parse("{USER_ID}")
});

Get User (By Email)

GET https://api.codemash.io/:version/membership/users/by-email

Gets a project user by email.

Path Parameters

NameTypeDescription

version

string

A version of the API endpoint.

Query Parameters

NameTypeDescription

IncludeUnreadNotifications

boolean

Includes unread push notifications count.

includePermissions

boolean

Includes permissions to the response.

includeDevices

boolean

Includes devices to the response.

includeMeta

boolean

Includes meta to the response.

Headers

NameTypeDescription

Authorization

string

Secret API key which belongs to your project or user. Not required if using cookies with a session ID.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

{
    "totalCount": 20,
    "result": [
        {
            "id": "{USER_ID}",
            "email": "test@test.com"
            ...
        },
        ...
    ]
}
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);

var response = await membershipService.GetUserAsync(new GetUserRequest
{
    Email = "john.doe@email.com"
});

Update profile

PATCH https://api.codemash.io/:version/membership/users/profile

Updates the user's profile with given parameters. Only the provided values are updated. This request does not update user roles.

Path Parameters

NameTypeDescription

version

string

A version of the API endpoint.

Headers

NameTypeDescription

Authorization

string

Secret API key which belongs to your project or user. Not required if using cookies with a session ID.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

Request Body

NameTypeDescription

unsubscribedNewsTags

array

Marketing email types to unsubscribe from. If value not provided then it's not updated. To delete, pass an empty array.

subscribeToNews

boolean

Should a user receive marketing emails? If value not provided then it's not updated.

timeZone

string

Default user's timezone.

language

string

Default user's language (mainly for notifications).

displayName

string

User's display name.

firstName

string

User's first name.

lastName

string

User's last name.

meta

string

User's meta details as JSON.

{
    "result": true
}
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"
});

Update user

PATCH https://api.codemash.io/:version/membership/users/:id

Updates user with given parameters. Only the provided values are updated. This request allows us to update user roles.

Path Parameters

NameTypeDescription

version

string

A version of the API endpoint.

id

string

User's ID.

Headers

NameTypeDescription

Authorization

string

Secret API key which belongs to your project or user. Not required if using cookies with a session ID.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

Request Body

NameTypeDescription

unsubscribedNewsTags

array

Marketing email types to unsubscribe from. If value not provided then it's not updated. To delete, pass an empty array.

subscribeToNews

boolean

Should user receive marketing emails? If value not provided then it's not updated.

timeZone

string

Default user's timezone.

language

string

Default user's language (mainly for notifications).

displayName

string

User's display name.

firstName

string

User's first name.

lastName

string

User's last name.

roles

array

Roles to set for a user.

meta

string

User's meta details as JSON.

{
    "result": true
}
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"
});

Delete user

DELETE https://api.codemash.io/:version/membership/users/:id

Deletes a project user.

Path Parameters

NameTypeDescription

version

string

A version of the API endpoint.

id

string

User's ID.

Headers

NameTypeDescription

Authorization

string

Secret API key which belongs to your project or user. Not required if using cookies with a session ID.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

{
    "result": true
}
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);

var reponse = await membershipService.DeleteUserAsync(new DeleteUserRequest
{
    Id = Guid.Parse("{USER_ID}"),
});

Block user

PATCH https://api.codemash.io/:version/membership/users/:id/block

Blocks users from calling any authenticated requests.

Path Parameters

NameTypeDescription

version

string

A version of the API endpoint.

id

string

User's ID.

Headers

NameTypeDescription

Authorization

string

Secret API key which belongs to your project or user. Not required if using cookies with a session ID.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

{
    "result": true
}
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);

var reponse = await membershipService.DeleteUserAsync(new DeleteUserRequest
{
    Id = Guid.Parse("{USER_ID}"),
});

Unblock user

PATCH https://api.codemash.io/:version/membership/users/:id/unblock

Unblocks user allowing to call authenticated calls.

Path Parameters

NameTypeDescription

version

string

A version of the API endpoint.

id

string

User's ID.

Headers

NameTypeDescription

Authorization

string

Secret API key which belongs to your project or user. Not required if using cookies with a session ID.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

{
    "result": true
}
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);

var reponse = await membershipService.UnblockUserAsync(new UnblockUserRequest
{
    Id = Guid.Parse("{USER_ID}"),
});

Last updated