Add Sub-Account User Invite a user to any sub-account in your agency with a specified role.
Invite a user to any sub-account that belongs to your agency. Creates an invitation, sends the email via your agency’s Resend config, and returns a confirmation.
Idempotent refresh: If an unaccepted invitation already exists for the same email + sub_account_id, the existing invitation is refreshed (new token, new 7-day expiry, role/name updated) rather than duplicated.
The target sub_account_id must belong to the API key’s organization, otherwise the request is rejected with 403.
Endpoint
POST https://crmwebhook.com/functions/v1/crm-api/add-subaccount-user
Header Value Required X-API-Key or AuthorizationAgency API key (cfy_...) Required Content-Typeapplication/jsonRequired
Request Body
{
"email" : "[email protected] " ,
"role" : "sub_account_user" ,
"sub_account_id" : "8f3b1c4d-1111-2222-3333-444455556666" ,
"first_name" : "Jane" ,
"last_name" : "Doe" ,
"phone" : "+15551234567"
}
Body Parameters
Field Type Required Description emailstringRequired Email address of the invitee. Stored lowercased. rolestringRequired One of: sub_account_owner, sub_account_admin, sub_account_user sub_account_idstring (UUID)Required Target sub-account. Must belong to the API key’s organization. first_namestringOptional Used in the invitation email last_namestringOptional Used in the invitation email phonestringOptional Stored on the invitation row
Allowed Roles
Value Display Name sub_account_ownerAccount Owner sub_account_adminAccount Admin sub_account_userAccount User
Agency-level roles (white_label_owner, etc.) and platform roles (super_admin) cannot be invited through this endpoint.
Example — Minimal
curl -X POST https://crmwebhook.com/functions/v1/crm-api/add-subaccount-user \
-H "X-API-Key: cfy_xxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected] ",
"role": "sub_account_user",
"sub_account_id": "8f3b1c4d-1111-2222-3333-444455556666"
}'
Example — With name and phone
curl -X POST https://crmwebhook.com/functions/v1/crm-api/add-subaccount-user \
-H "X-API-Key: cfy_xxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected] ",
"role": "sub_account_admin",
"sub_account_id": "8f3b1c4d-1111-2222-3333-444455556666",
"first_name": "Jane",
"last_name": "Doe",
"phone": "+15551234567"
}'
Response Shape
{
"message" : "Invitation is sent to [email protected] "
}
Response Codes
Status Meaning 201Invitation created and email sent 400Missing required field, invalid email format, or invalid role 401Missing or invalid API key 403Sub-account belongs to a different organization, or user limit reached 404Sub-account ID not found 502Invitation created but email failed to send (invitation token still returned for retry)
If you get a 502, the invitation row was still created. Call this endpoint again with the same email + sub_account_id to refresh the invitation and retry the email send.