Invite a user to a Team
POST
/api/v2/account_invites
const url = 'https://api.payhero.africa/api/v2/account_invites';const options = { method: 'POST', headers: {Authorization: 'Basic <credentials>', 'Content-Type': 'application/json'}, body: '{"organization_id":9,"account_id":63,"email":"agent@vendor-a.co","phone_number":"+254720111222","role_id":3,"assigned_account_ids":[63],"base_url":"https://app.acme.co"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.payhero.africa/api/v2/account_invites \ --header 'Authorization: Basic <credentials>' \ --header 'Content-Type: application/json' \ --data '{ "organization_id": 9, "account_id": 63, "email": "agent@vendor-a.co", "phone_number": "+254720111222", "role_id": 3, "assigned_account_ids": [ 63 ], "base_url": "https://app.acme.co" }'Sends an invitation to join a Team. The invitee gets an invite link built
from base_url; on acceptance they are granted role_id on the Team.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
organization_id
required
integer
account_id
required
The Team to invite the user into.
integer
email
required
string
phone_number
string
role_id
Role granted on acceptance — scopes the member’s permissions.
integer
assigned_account_ids
Teams the member is granted access to.
Array<integer>
base_url
Base URL used to build the invite link in the email.
string
Examples
ExampleInvite an agent
{ "organization_id": 9, "account_id": 63, "email": "agent@vendor-a.co", "phone_number": "+254720111222", "role_id": 3, "assigned_account_ids": [ 63 ], "base_url": "https://app.acme.co"}Responses
Section titled “Responses”Invitation sent.
Media typeapplication/json
object
success
boolean
Example
{ "success": true}The request was rejected (validation or business-rule failure).
Media typeapplication/json
object
error_code
string
error_message
string
status_code
integer
Examples
{ "error_code": "invalid_argument", "error_message": "the transaction amount is insufficient as it wont cater for cost: (4.62)", "status_code": 400}{ "error_code": "invalid_argument", "error_message": "The passed channel is not active", "status_code": 400}Missing or invalid Basic auth credentials.
Media typeapplication/json
object
error_code
string
error_message
string
status_code
integer
Example
{ "error_code": "invalid_argument", "error_message": "the transaction amount is insufficient as it wont cater for cost: (4.62)", "status_code": 400}
