Invitations

An Invitation can be used to allow users to claim ownership of a resource on the Centrapay platform.

Attributes

  • id

    string

    The Invitation’s unique identifier.

  • code

    string

    The Invitation code.

  • type

    string

    The type of invitation. Supported values are account-membership.

  • resourceId

    string

    The id of the related resource.

  • resourceType

    string

    The type of the related resource. Supported values are account.

  • expiresAt

    timestamp

    When the Invitation expires.

  • createdAt

    timestamp

    When the Invitation was created.

  • createdBy

    crn

    The User or API Key that created the Invitation.

  • updatedAt

    timestamp

    When the Invitation was updated.

  • updatedBy

    crn

    The User or API Key that updated the Invitation.

  • accepted

    boolean

    A flag indicating whether the Invitation has been accepted.

  • acceptedAt

    timestamp

    When the Invitation was accepted.

  • acceptedBy

    crn

    The User or API Key that accepted the Invitation.

  • acceptedByAccountId

    string

    The Account id of the user accepting the Invitation.

  • recipientAlias

    string

    The email address of the user accepting the Invitation.

  • params

    object

    Params dependent on the Invitation type.

  • status

    string

    The status of the invitation. Possible values are created, sent, accepted and revoked.


Attributes

  • role

    string

    The role assigned to the recipient, for invitations of type account-membership.

  • accountName

    string

    The name of the account that the recipient is invited to, for invitations of type account-membership


POST /api/invitations

This endpoint allows you to create an Invitation.

Attributes

  • type

    string required

    The type of invitation. Supported values are account-membership.

  • resourceId

    string required

    The id of the related resource.

  • resourceType

    string required

    The type of the related resource. Supported values are account.

  • recipientAlias

    string required

    The email address of the user accepting the Invitation.

  • params

    object required

    Params depending on the Invitation type.

  • role

    string required

    The role that will be assigned to the user when the Invitation is accepted.

Errors

  • INVALID_ACCOUNT_TYPE

    403

    The resourceId is associated with an account with a non org type.

  • RECIPIENT_ALREADY_INVITED

    403

    An active invitation for this recipientAlias and resource already exists, or the recipient has already joined the resource.

Request
curl -X POST \
https://service.centrapay.com/api/invitations \
-H 'content-type: application/json' \
-H 'x-api-key: <TOKEN>' \
-d '
{
"type": "account-membership",
"resourceId": "Hopo4g34sLVdjEMBs2p19F",
"resourceType": "account",
"recipientAlias": "user@org.com",
"params": {
"role": "cashier"
}
}
'
Response
{
"id": "DKTs3U38hdhfEqwF1JKoT2",
"code": "WIj211vFs9cNACwBb04vQw",
"type": "account-membership",
"resourceId": "Hopo4g34sLVdjEMBs2p19F",
"resourceType": "account",
"expiresAt": "2021-08-26T00:02:49.488Z",
"createdAt": "2021-08-25T00:02:49.488Z",
"createdBy": "crn:WIj211vFs9cNACwBb04vQw:api-key:MyApiKey",
"updatedAt": "2021-08-25T00:02:49.488Z",
"updatedBy": "crn:WIj211vFs9cNACwBb04vQw:api-key:MyApiKey",
"recipientAlias": "user@org.com",
"params": {
"role": "cashier",
"accountName": "Centrapay Cafe"
},
"status": "created"
}

GET /api/invitations/code/{code}

This endpoint allows you to retrieve an Invitation by code.

Request
curl -X GET \
https://service.centrapay.com/api/invitations/code/WIj211vFs9cNACwBb04vQw \
-H 'x-api-key: <TOKEN>'
Response
{
"id": "DKTs3U38hdhfEqwF1JKoT2",
"code": "WIj211vFs9cNACwBb04vQw",
"type": "account-membership",
"resourceId": "5ee0c486308f590260d9a07f",
"resourceType": "account",
"expiresAt": "2021-08-26T00:02:49.488Z",
"createdAt": "2021-08-25T00:02:49.488Z",
"createdBy": "crn:WIj211vFs9cNACwBb04vQw:api-key:MyApiKey",
"updatedAt": "2021-08-25T00:02:49.488Z",
"updatedBy": "crn:WIj211vFs9cNACwBb04vQw:api-key:MyApiKey"
}

GET /api/accounts/{accountId}/invitations

This endpoint allows you list Invitations for an Account.

Request
curl -X GET \
https://service.centrapay.com/api/accounts/8usozbJzCJYjR8i7y92vMV/invitations \
-H 'x-api-key: <TOKEN>'
Response
{
"items": [
{
"id": "DKTs3U38hdhfEqwF1JKoT2",
"code": "WIj211vFs9cNACwBb04vQw",
"type": "account-membership",
"resourceId": "Hopo4g34sLVdjEMBs2p19F",
"resourceType": "account",
"expiresAt": "2021-08-26T00:02:49.488Z",
"createdAt": "2021-08-25T00:02:49.488Z",
"createdBy": "crn:WIj211vFs9cNACwBb04vQw:api-key:MyApiKey",
"updatedAt": "2021-08-25T00:02:49.488Z",
"updatedBy": "crn:WIj211vFs9cNACwBb04vQw:api-key:MyApiKey",
"recipientAlias": "user@org.com",
"params": {
"role": "account-owner",
"accountName": "Centrapay Cafe"
},
"status": "created"
},
{
"id": "JKKDMU38hd01hfEqwF1oT2",
"code": "WIj211vFs9cNACwBb04vQw",
"type": "account-membership",
"resourceId": "Hopo4g34sLVdjEMBs2p19F",
"resourceType": "account",
"expiresAt": "2021-08-26T00:02:49.488Z",
"createdAt": "2021-08-25T00:02:49.488Z",
"createdBy": "crn:WIj211vFs9cNACwBb04vQw:api-key:MyApiKey",
"updatedAt": "2021-08-25T00:02:49.488Z",
"updatedBy": "crn:WIj211vFs9cNACwBb04vQw:api-key:MyApiKey",
"recipientAlias": "john.doe@org.com",
"params": {
"role": "cashier",
"accountName": "Centrapay Tea Warehouse"
},
"status": "sent"
}
]
}

POST /api/invitations/{invitationId}/accept

This endpoint allows you to accept an Invitation.

Attributes

  • code

    string required

    The Invitation code.

  • accountId

    string required

    The Account id of the user accepting the Invitation.

Errors

  • INVITATION_EXPIRED

    403

    The Invitation is expired.

  • INVITATION_ALREADY_ACCEPTED

    403

    The Invitation has already been accepted.

  • RECIPIENT_ALIAS_MISMATCH

    403

    The alias of the user accepting an Invitation is not the same as the recipientAlias of the Invitation.

  • INVITATION_REVOKED

    403

    The Invitation was revoked.

Request
curl -X POST \
https://service.centrapay.com/api/invitations/DKTs3U38hdhfEqwF1JKoT2/accept \
-H 'content-type: application/json' \
-H 'x-api-key: <TOKEN>' \
-d '
{
"code": "WIj211vFs9cNACwBb04vQw",
"accountId": "Jaim1Cu1Q55uooxSens6yk"
}
'
Response
{
"id": "DKTs3U38hdhfEqwF1JKoT2",
"code": "WIj211vFs9cNACwBb04vQw",
"type": "account-membership",
"resourceId": "5ee0c486308f590260d9a07f",
"resourceType": "account",
"expiresAt": "2021-08-26T00:02:49.488Z",
"createdAt": "2021-08-25T00:02:49.488Z",
"createdBy": "crn:WIj211vFs9cNACwBb04vQw:api-key:MyApiKey",
"accepted": true,
"acceptedAt": "2021-08-25T10:12:22.122Z",
"acceptedBy": "crn::user:e2837e88-d408-11eb-8eac-3e22fb52e878",
"acceptedByAccountId": "Jaim1Cu1Q55uooxSens6yk",
"updatedAt": "2021-08-25T10:12:22.122Z",
"updatedBy": "crn::user:e2837e88-d408-11eb-8eac-3e22fb52e878"
}

POST /api/invitations/{invitationId}/revoke

This endpoint allows you to revoke an Invitation.

Errors

  • INVITATION_EXPIRED

    403

    The Invitation is expired.

  • INVITATION_ACCEPTED

    403

    The Invitation has already been accepted.

Request
curl -X POST \
https://service.centrapay.com/api/invitations/DKTs3U38hdhfEqwF1JKoT2/revoke \
-H 'x-api-key: <TOKEN>'
Response
{
"id": "DKTs3U38hdhfEqwF1JKoT2",
"code": "WIj211vFs9cNACwBb04vQw",
"type": "account-membership",
"resourceId": "Hopo4g34sLVdjEMBs2p19F",
"resourceType": "account",
"recipientAlias": "user@org.com",
"params": {
"role": "cashier",
"accountName": "Centrapay Cafe"
},
"createdAt": "2021-08-25T00:02:49.488Z",
"expiresAt": "2021-08-26T00:02:49.488Z",
"createdBy": "crn::user:1234",
"updatedAt": "2021-08-25T00:00:00.000Z",
"updatedBy": "crn::user:1234",
"status": "revoked"
}