This is the API Documentation for Somleng Simple Call Flow Manager (Somleng SCFM).
Access Tokens
Create an Access Token
Request
curl "https://scfm.somleng.org/api/access_tokens" -d '{
"metadata": {
"foo": "bar"
},
"permissions": [
"contacts_write"
]
}' -X POST \
-H "Authorization: Bearer nHXcrluCs2e2opYsVNPnu2Jr_b5dUCntxuytAJhXF9Y"
Endpoint
POST /api/access_tokens
POST /api/access_tokens
Parameters
{
"metadata": {
"foo": "bar"
},
"permissions": [
"contacts_write"
]
}
Name | Description |
---|---|
permissions | An array of permissions for the access token. Valid permissions are: access_tokens_read , access_tokens_write , accounts_read , accounts_write , batch_operations_read , batch_operations_write , callout_participations_read , callout_participations_write , callouts_read , callouts_write , contacts_read , contacts_write , phone_calls_read , phone_calls_write , remote_phone_call_events_read , remote_phone_call_events_write , users_read , users_write , recordings_read |
Response
location: /api/access_tokens/16
201 Created
{
"id": 16,
"token": "Q6wv836aBxcVIu6mjvTq3cHMIwE9V8Lgt4RtDzyMPs8",
"created_at": "2024-11-27T11:10:06.112Z",
"updated_at": "2024-11-27T11:10:06.113Z",
"metadata": {
"foo": "bar"
},
"permissions": [
"contacts_write"
]
}
Delete an Access Token
Request
curl "https://scfm.somleng.org/api/access_tokens/21" -d '' -X DELETE \
-H "Authorization: Bearer R7f28NjTSbIWS8d-ZOrAC67mf_bfNpLuvJb68pFdkVg"
Endpoint
DELETE /api/access_tokens/:id
DELETE /api/access_tokens/21
Parameters
None known.
Response
location: /api/access_tokens
204 No Content
List all Access Tokens
Request
curl -g "https://scfm.somleng.org/api/access_tokens?q[metadata][foo]=bar" -X GET \
-H "Authorization: Bearer V8uBW4E_vT2AOzVsRU4CK7uXmhttTobcEMMgRXHa5RQ"
Endpoint
GET /api/access_tokens
GET /api/access_tokens?q[metadata][foo]=bar
Parameters
q: {"metadata"=>{"foo"=>"bar"}}
Name | Description |
---|---|
q | A filter in which to filter resources |
Response
per-page: 25
total: 1
200 OK
[
{
"id": 11,
"token": "NvLYSrCnQiLgek1zvPp4gdBfSiHm8QwD_Lf82DbFAlY",
"created_at": "2024-11-27T11:10:06.053Z",
"updated_at": "2024-11-27T11:10:06.054Z",
"metadata": {
"foo": "bar"
},
"permissions": []
}
]
Retrieve an Access Token
Request
curl -g "https://scfm.somleng.org/api/access_tokens/19" -X GET \
-H "Authorization: Bearer gt4jJunpF5urU5S2OaM2xw0TLSof9K0QYH3S5passfc"
Endpoint
GET /api/access_tokens/:id
GET /api/access_tokens/19
Parameters
None known.
Response
location: /api/access_tokens/19
200 OK
{
"id": 19,
"token": "gt4jJunpF5urU5S2OaM2xw0TLSof9K0QYH3S5passfc",
"created_at": "2024-11-27T11:10:06.144Z",
"updated_at": "2024-11-27T11:10:06.146Z",
"metadata": {},
"permissions": [
"access_tokens_read",
"access_tokens_write"
]
}
Update an Access Token
Request
curl "https://scfm.somleng.orgapi/access_tokens/20" -d '{
"metadata": {
"foo": "bar"
},
"metadata_merge_mode": "replace"
}' -X PATCH \
-H "Authorization: Bearer 6GoO_M8ZfJMhg9OWOO2c6zDZwI0Clbm2voePVZE0ovY"
Endpoint
PATCH api/access_tokens/:id
PATCH api/access_tokens/20
Parameters
{
"metadata": {
"foo": "bar"
},
"metadata_merge_mode": "replace"
}
None known.
Response
location: /api/access_tokens/20
204 No Content
Account Details
Retrieve Account Details
Request
curl -g "https://scfm.somleng.org/api/account" -X GET \
-H "Authorization: Bearer aZaSXK5trzawWCgQo3XreKtwhX4YFhQ9PcJqvk5mJqI"
Endpoint
GET /api/account
GET /api/account
Parameters
None known.
Response
location: /api/accounts/399
200 OK
{
"id": 399,
"metadata": {},
"settings": {
"from_phone_number": "1234",
"phone_call_queue_limit": 200,
"max_phone_calls_for_callout_participation": 3
},
"twilio_account_sid": null,
"somleng_account_sid": null,
"twilio_auth_token": null,
"somleng_auth_token": null,
"permissions": [],
"created_at": "2024-11-27T11:10:06.203Z",
"updated_at": "2024-11-27T11:10:06.203Z",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"platform_provider_name": null,
"somleng_api_host": null,
"somleng_api_base_url": null
}
Update Account Details
Request
curl "https://scfm.somleng.org/api/account" -d '{
"metadata": {
"foo": "bar"
},
"metadata_merge_mode": "replace"
}' -X PATCH \
-H "Authorization: Bearer hQCiM_EmAFz9BREd45Qy54NE9cfc15zhGvKg53vVCkA"
Endpoint
PATCH /api/account
PATCH /api/account
Parameters
{
"metadata": {
"foo": "bar"
},
"metadata_merge_mode": "replace"
}
None known.
Response
location: /api/accounts/400
204 No Content
Accounts
Only super admins can manage accounts.
Create an Account
Request
curl "https://scfm.somleng.org/api/accounts" -d '' -X POST \
-H "Authorization: Bearer DOtV52vDPOllbf_j_tVnhoeR-kGIuTwXHn11XK14Wf8"
Endpoint
POST /api/accounts
POST /api/accounts
Parameters
None known.
Response
location: /api/accounts/405
201 Created
{
"id": 405,
"metadata": {},
"settings": {
"from_phone_number": "1234",
"phone_call_queue_limit": 200,
"max_phone_calls_for_callout_participation": 3
},
"twilio_account_sid": null,
"somleng_account_sid": null,
"twilio_auth_token": null,
"somleng_auth_token": null,
"permissions": [],
"created_at": "2024-11-27T11:10:06.258Z",
"updated_at": "2024-11-27T11:10:06.258Z",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"platform_provider_name": null,
"somleng_api_host": null,
"somleng_api_base_url": null
}
Delete an Account
Request
curl "https://scfm.somleng.org/api/accounts/410" -d '' -X DELETE \
-H "Authorization: Bearer oI00G_mgSSDrB-bIeGR8ktbSP7R7X0Jpt8dcK8FAr4Y"
Endpoint
DELETE /api/accounts/:id
DELETE /api/accounts/410
Parameters
None known.
Response
location: /api/accounts
204 No Content
List all Accounts
Request
curl -g "https://scfm.somleng.org/api/accounts?q[metadata][foo]=bar" -X GET \
-H "Authorization: Bearer Lqs3TqBlOdqcbV1_v5t11fip4BW1aEUNqHEc34de5c0"
Endpoint
GET /api/accounts
GET /api/accounts?q[metadata][foo]=bar
Parameters
q: {"metadata"=>{"foo"=>"bar"}}
None known.
Response
per-page: 25
total: 1
200 OK
[
{
"id": 401,
"metadata": {
"foo": "bar"
},
"settings": {
"from_phone_number": "1234",
"phone_call_queue_limit": 200,
"max_phone_calls_for_callout_participation": 3
},
"twilio_account_sid": null,
"somleng_account_sid": null,
"twilio_auth_token": null,
"somleng_auth_token": null,
"permissions": [],
"created_at": "2024-11-27T11:10:06.228Z",
"updated_at": "2024-11-27T11:10:06.228Z",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"platform_provider_name": null,
"somleng_api_host": null,
"somleng_api_base_url": null
}
]
Retrieve an Account
Request
curl -g "https://scfm.somleng.org/api/accounts/406" -X GET \
-H "Authorization: Bearer 88OzDOHD2fIXBuyQxok34EOyjOkSkQNdVcm5AFNNuCY"
Endpoint
GET /api/accounts/:id
GET /api/accounts/406
Parameters
None known.
Response
location: /api/accounts/406
200 OK
{
"id": 406,
"metadata": {},
"settings": {
"from_phone_number": "1234",
"phone_call_queue_limit": 200,
"max_phone_calls_for_callout_participation": 3
},
"twilio_account_sid": null,
"somleng_account_sid": null,
"twilio_auth_token": null,
"somleng_auth_token": null,
"permissions": [],
"created_at": "2024-11-27T11:10:06.264Z",
"updated_at": "2024-11-27T11:10:06.264Z",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"platform_provider_name": null,
"somleng_api_host": null,
"somleng_api_base_url": null
}
Update an Account
Request
curl "https://scfm.somleng.org/api/accounts/408" -d '{
"metadata": {
"foo": "bar"
},
"metadata_merge_mode": "replace",
"twilio_account_sid": "AC8",
"somleng_account_sid": "e730e3d5-3182-4d89-986f-468618f54064",
"twilio_auth_token": "df8413d6-4922-4603-977d-3882bc59db3c",
"somleng_auth_token": "4b325309-f071-4b0e-b9f8-8ecd2f6b8154",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"platform_provider_name": "somleng",
"settings": {
"batch_operation_phone_call_create_parameters": {
"callout_filter_params": {
"status": "running"
},
"callout_participation_filter_params": {
"no_phone_calls_or_last_attempt": "failed"
},
"remote_request_params": {
"from": "1234",
"url": "https://demo.twilio.com/docs/voice.xml",
"method": "GET"
}
},
"batch_operation_phone_call_queue_parameters": {
"callout_filter_params": {
"status": "running"
},
"phone_call_filter_params": {
"status": "created"
},
"limit": "30"
},
"batch_operation_phone_call_queue_remote_fetch_parameters": {
"phone_call_filter_params": {
"status": "remotely_queued,in_progress"
},
"limit": "30"
}
}
}' -X PATCH \
-H "Authorization: Bearer 77X4OInovERKRw8axXcqeTrRyLCFgkuR9AJqg-RxsfA"
Endpoint
PATCH /api/accounts/:id
PATCH /api/accounts/408
Parameters
{
"metadata": {
"foo": "bar"
},
"metadata_merge_mode": "replace",
"twilio_account_sid": "AC8",
"somleng_account_sid": "e730e3d5-3182-4d89-986f-468618f54064",
"twilio_auth_token": "df8413d6-4922-4603-977d-3882bc59db3c",
"somleng_auth_token": "4b325309-f071-4b0e-b9f8-8ecd2f6b8154",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"platform_provider_name": "somleng",
"settings": {
"batch_operation_phone_call_create_parameters": {
"callout_filter_params": {
"status": "running"
},
"callout_participation_filter_params": {
"no_phone_calls_or_last_attempt": "failed"
},
"remote_request_params": {
"from": "1234",
"url": "https://demo.twilio.com/docs/voice.xml",
"method": "GET"
}
},
"batch_operation_phone_call_queue_parameters": {
"callout_filter_params": {
"status": "running"
},
"phone_call_filter_params": {
"status": "created"
},
"limit": "30"
},
"batch_operation_phone_call_queue_remote_fetch_parameters": {
"phone_call_filter_params": {
"status": "remotely_queued,in_progress"
},
"limit": "30"
}
}
}
None known.
Response
location: /api/accounts/408
204 No Content
Batch Operations
Create a Batch Operation Event
Request
curl "https://scfm.somleng.org/api/batch_operations/28/batch_operation_events" -d '{
"event": "queue"
}' -X POST \
-H "Authorization: Bearer WVtfeJx6NUInFPf24IGDliZAVR1-SMmiZIk8QPKmyR8"
Endpoint
POST /api/batch_operations/:batch_operation_id/batch_operation_events
POST /api/batch_operations/28/batch_operation_events
Parameters
{
"event": "queue"
}
Name | Description |
---|---|
event required | Either queue . |
Response
location: /api/batch_operations/28
201 Created
{
"id": 28,
"callout_id": 193,
"parameters": {},
"metadata": {},
"status": "queued",
"created_at": "2024-11-27T11:10:06.536Z",
"updated_at": "2024-11-27T11:10:06.536Z",
"account_id": 425,
"type": "BatchOperation::CalloutPopulation"
}
Delete a Batch Operation
Request
curl "https://scfm.somleng.org/api/batch_operations/26" -d '' -X DELETE \
-H "Authorization: Bearer xvh3TUSU0K8XUpTmRYsLmZ4EcY4r6WtybkcHQTpXz68"
Endpoint
DELETE /api/batch_operations/:id
DELETE /api/batch_operations/26
Parameters
None known.
Response
location: /api/batch_operations
204 No Content
List all Batch Operations
Request
curl -g "https://scfm.somleng.org/api/batch_operations?q[callout_id]=183" -X GET \
-H "Authorization: Bearer Gxp7D5q8r8rBWXkLYA98r8j2fWtgBS58_cnXa9CUzyA"
Endpoint
GET /api/batch_operations
GET /api/batch_operations?q[callout_id]=183
Parameters
q: {"callout_id"=>"183"}
None known.
Response
per-page: 25
total: 1
200 OK
[
{
"id": 20,
"callout_id": 183,
"parameters": {},
"metadata": {},
"status": "preview",
"created_at": "2024-11-27T11:10:06.346Z",
"updated_at": "2024-11-27T11:10:06.346Z",
"account_id": 414,
"type": "BatchOperation::CalloutPopulation"
}
]
Populate a Callout
Creates a batch operation for populating a callout with callout participations.
Specify contact_filter_params
in order to filter which contacts will participate in the callout.
Request
curl "https://scfm.somleng.org/api/batch_operations" -d '{
"callout_id": 186,
"metadata": {
"foo": "bar"
},
"parameters": {
"contact_filter_params": {
"metadata": {
"gender": "f",
"date_of_birth.date.gteq": "2022-01-01",
"date_of_birth.date.lt": "2022-02-01",
"deregistered_at.exists": false
}
}
},
"type": "BatchOperation::CalloutPopulation"
}' -X POST \
-H "Authorization: Bearer MnA6fHmb825pwE6clqY05ggGmdMXgoneWxNlOXzrzEI"
Endpoint
POST /api/batch_operations
POST /api/batch_operations
Parameters
{
"callout_id": 186,
"metadata": {
"foo": "bar"
},
"parameters": {
"contact_filter_params": {
"metadata": {
"gender": "f",
"date_of_birth.date.gteq": "2022-01-01",
"date_of_birth.date.lt": "2022-02-01",
"deregistered_at.exists": false
}
}
},
"type": "BatchOperation::CalloutPopulation"
}
Name | Description |
---|---|
type required | Must be: BatchOperation::CalloutPopulation |
parameters | Parameters for the batch operation. |
contact_filter_params
filter the contacts by the specified params.
|
| callout_id | The id
of the callout. |
Response
location: /api/batch_operations/23
201 Created
{
"id": 23,
"callout_id": 186,
"parameters": {
"contact_filter_params": {
"metadata": {
"gender": "f",
"date_of_birth.date.gteq": "2022-01-01",
"date_of_birth.date.lt": "2022-02-01",
"deregistered_at.exists": false
}
}
},
"metadata": {
"foo": "bar"
},
"status": "preview",
"created_at": "2024-11-27T11:10:06.386Z",
"updated_at": "2024-11-27T11:10:06.386Z",
"account_id": 416,
"type": "BatchOperation::CalloutPopulation"
}
Retrieve a Batch Operation
Request
curl -g "https://scfm.somleng.org/api/batch_operations/24" -X GET \
-H "Authorization: Bearer ZnBitWSkTnvi_6E4gng8oy_JJCO70SBGxyRVBnHKcAc"
Endpoint
GET /api/batch_operations/:id
GET /api/batch_operations/24
Parameters
None known.
Response
location: /api/batch_operations/24
200 OK
{
"id": 24,
"callout_id": 188,
"parameters": {},
"metadata": {},
"status": "preview",
"created_at": "2024-11-27T11:10:06.434Z",
"updated_at": "2024-11-27T11:10:06.434Z",
"account_id": 419,
"type": "BatchOperation::CalloutPopulation"
}
Update a Batch Operation
Request
curl "https://scfm.somleng.org/api/batch_operations/25" -d '{
"metadata": {
"foo": "bar",
"bar": "foo"
},
"parameters": {
"contact_filter_params": {
"metadata": {
"foo": "bar"
}
}
},
"metadata_merge_mode": "replace"
}' -X PATCH \
-H "Authorization: Bearer V6AboPeg5q-rpF8jrUYi5SFZCFliaadHI5Mt1I0IUVU"
Endpoint
PATCH /api/batch_operations/:id
PATCH /api/batch_operations/25
Parameters
{
"metadata": {
"foo": "bar",
"bar": "foo"
},
"parameters": {
"contact_filter_params": {
"metadata": {
"foo": "bar"
}
}
},
"metadata_merge_mode": "replace"
}
None known.
Response
location: /api/batch_operations/25
204 No Content
Callout Participations
Create a Callout Participation
Request
curl "https://scfm.somleng.org/api/callouts/202/callout_participations" -d '{
"contact_id": 207,
"msisdn": "252662345997",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"metadata": {
"foo": "bar"
}
}' -X POST \
-H "Authorization: Bearer OihA1YsXA1HgfXkmuxM5QDRA6q_C-k0jrfK-kLvEvK0"
Endpoint
POST /api/callouts/:callout_id/callout_participations
POST /api/callouts/202/callout_participations
Parameters
{
"contact_id": 207,
"msisdn": "252662345997",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"metadata": {
"foo": "bar"
}
}
None known.
Response
location: /api/callout_participations/166
201 Created
{
"id": 166,
"callout_id": 202,
"contact_id": 207,
"callout_population_id": null,
"msisdn": "+252662345997",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"metadata": {
"foo": "bar"
},
"created_at": "2024-11-27T11:10:06.698Z",
"updated_at": "2024-11-27T11:10:06.698Z",
"answered": false,
"phone_calls_count": 0
}
Create a Callout Participation with invalid data
Request
curl "https://scfm.somleng.org/api/callouts/203/callout_participations" -d '' -X POST \
-H "Authorization: Bearer v6d7IB5_yYtetWewmX_dYuCq8i_ECEZTdqYPWxfg8ZY"
Endpoint
POST /api/callouts/:callout_id/callout_participations
POST /api/callouts/203/callout_participations
Parameters
None known.
Response
422 Unprocessable Content
{
"errors": {
"msisdn": [
"can't be blank"
],
"contact": [
"must exist"
]
}
}
Delete a Callout Participation
Request
curl "https://scfm.somleng.org/api/callout_participations/169" -d '' -X DELETE \
-H "Authorization: Bearer FXO48KaTAHM0u4s0Gt2Qm4t-rWeK46KHelCCkSiXQXI"
Endpoint
DELETE /api/callout_participations/:id
DELETE /api/callout_participations/169
Parameters
None known.
Response
location: /api/callout_participations
204 No Content
Delete a Callout Participation with phone calls
Request
curl "https://scfm.somleng.org/api/callout_participations/170" -d '' -X DELETE \
-H "Authorization: Bearer mK7KHzAglH3Stni0uQJzqOMGpPG7nhmNeeHwMXsssng"
Endpoint
DELETE /api/callout_participations/:id
DELETE /api/callout_participations/170
Parameters
None known.
Response
422 Unprocessable Content
{
"errors": {
"base": [
"Cannot delete record because dependent phone calls exist"
]
}
}
List all Callout Participations
Request
curl -g "https://scfm.somleng.org/api/callout_participations?q[metadata][foo]=bar" -X GET \
-H "Authorization: Bearer lc0WfGkFVDCTVHz0XC_aA7NWN76jeuBxZnTP2c3e1Zs"
Endpoint
GET /api/callout_participations
GET /api/callout_participations?q[metadata][foo]=bar
Parameters
q: {"metadata"=>{"foo"=>"bar"}}
None known.
Response
per-page: 25
total: 1
200 OK
[
{
"id": 159,
"callout_id": 195,
"contact_id": 200,
"callout_population_id": null,
"msisdn": "+252662345989",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"metadata": {
"foo": "bar"
},
"created_at": "2024-11-27T11:10:06.589Z",
"updated_at": "2024-11-27T11:10:06.589Z",
"answered": false,
"phone_calls_count": 0
}
]
Retrieve a Callout Participation
Request
curl -g "https://scfm.somleng.org/api/callout_participations/167" -X GET \
-H "Authorization: Bearer oAQiOIhOu36UO0G3bIpjfAjzKTKunX5ZGFAZJWoG5Tg"
Endpoint
GET /api/callout_participations/:id
GET /api/callout_participations/167
Parameters
None known.
Response
location: /api/callout_participations/167
200 OK
{
"id": 167,
"callout_id": 204,
"contact_id": 208,
"callout_population_id": null,
"msisdn": "+252662345998",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"metadata": {},
"created_at": "2024-11-27T11:10:06.731Z",
"updated_at": "2024-11-27T11:10:06.731Z",
"answered": false,
"phone_calls_count": 0
}
Update a Callout Participation
Request
curl "https://scfm.somleng.org/api/callout_participations/168" -d '{
"contact_id": 210,
"msisdn": "252662346001",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"metadata": {
"bar": "foo"
},
"metadata_merge_mode": "replace"
}' -X PATCH \
-H "Authorization: Bearer ASQHaKOMVTU806Az45ZtuVfwF5EvBbvXk2QsfjZOWFk"
Endpoint
PATCH /api/callout_participations/:id
PATCH /api/callout_participations/168
Parameters
{
"contact_id": 210,
"msisdn": "252662346001",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"metadata": {
"bar": "foo"
},
"metadata_merge_mode": "replace"
}
None known.
Response
location: /api/callout_participations/168
204 No Content
Callouts
Create a Callout
Request
curl "https://scfm.somleng.org/api/callouts" -d '{
"call_flow_logic": "CallFlowLogic::HelloWorld",
"audio_url": "https://www.example.com/sample.mp3",
"metadata": {
"foo": "bar"
},
"settings": {
"external_service_1": {
"foo": "bar"
}
}
}' -X POST \
-H "Authorization: Bearer vkOr5o2znT4r92W9X494mDguIgxXJ8BrLHepgRrZIKw"
Endpoint
POST /api/callouts
POST /api/callouts
Parameters
{
"call_flow_logic": "CallFlowLogic::HelloWorld",
"audio_url": "https://www.example.com/sample.mp3",
"metadata": {
"foo": "bar"
},
"settings": {
"external_service_1": {
"foo": "bar"
}
}
}
Name | Description |
---|---|
call_flow_logic | The name of the call flow logic to be run during the callout. |
audio_url | The URL to an audio file to be played during the callout. |
settings | Additionoal settings which are needed byt the call flow logic. |
Response
location: /api/callouts/213
201 Created
{
"id": 213,
"status": "initialized",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"metadata": {
"foo": "bar"
},
"created_at": "2024-11-27T11:10:06.867Z",
"updated_at": "2024-11-27T11:10:06.867Z",
"account_id": 441,
"audio_url": "https://www.example.com/sample.mp3",
"settings": {
"external_service_1": {
"foo": "bar"
}
},
"created_by_id": null
}
Create a Callout Event
Request
curl "https://scfm.somleng.org/api/callouts/218/callout_events" -d '{
"event": "start"
}' -X POST \
-H "Authorization: Bearer GXN1RBH3LcikXgRADZKxUnKacjYC14pKFXX74qbx1ow"
Endpoint
POST /api/callouts/:callout_id/callout_events
POST /api/callouts/218/callout_events
Parameters
{
"event": "start"
}
Name | Description |
---|---|
event required | One of: start , pause , resume , stop |
Response
location: /api/callouts/218
201 Created
{
"account_id": 446,
"id": 218,
"status": "running",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"metadata": {},
"created_at": "2024-11-27T11:10:06.943Z",
"updated_at": "2024-11-27T11:10:06.953Z",
"audio_url": null,
"settings": {},
"created_by_id": null
}
Delete a Callout
Request
curl "https://scfm.somleng.org/api/callouts/216" -d '' -X DELETE \
-H "Authorization: Bearer GvfjSE3z3wh987KlYQFHQe_cY-b3TyBN-0oU03GF0Vc"
Endpoint
DELETE /api/callouts/:id
DELETE /api/callouts/216
Parameters
None known.
Response
location: /api/callouts
204 No Content
List all Callouts
Request
curl -g "https://scfm.somleng.org/api/callouts?q[metadata][foo]=bar" -X GET \
-H "Authorization: Bearer vTKAhBpg2BhJH0sVWIgt60IqkiYPm_okNHqhMXn4bGQ"
Endpoint
GET /api/callouts
GET /api/callouts?q[metadata][foo]=bar
Parameters
q: {"metadata"=>{"foo"=>"bar"}}
None known.
Response
per-page: 25
total: 1
200 OK
[
{
"id": 208,
"status": "initialized",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"metadata": {
"foo": "bar"
},
"created_at": "2024-11-27T11:10:06.814Z",
"updated_at": "2024-11-27T11:10:06.814Z",
"account_id": 438,
"audio_url": null,
"settings": {},
"created_by_id": null
}
]
Retrieve a Callout
Request
curl -g "https://scfm.somleng.org/api/callouts/214" -X GET \
-H "Authorization: Bearer sAYTctmR7g8ip7kk-TUswZqASbH0rIC5G-JODYmJ_qc"
Endpoint
GET /api/callouts/:id
GET /api/callouts/214
Parameters
None known.
Response
location: /api/callouts/214
200 OK
{
"id": 214,
"status": "initialized",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"metadata": {},
"created_at": "2024-11-27T11:10:06.875Z",
"updated_at": "2024-11-27T11:10:06.875Z",
"account_id": 442,
"audio_url": null,
"settings": {},
"created_by_id": null
}
Update a Callout
Request
curl "https://scfm.somleng.org/api/callouts/215" -d '{
"metadata": {
"bar": "foo"
},
"metadata_merge_mode": "replace"
}' -X PATCH \
-H "Authorization: Bearer hVAVUMVu6XEpb9kscE2YKdlqPs_frbekmUcvQa8Lc44"
Endpoint
PATCH /api/callouts/:id
PATCH /api/callouts/215
Parameters
{
"metadata": {
"bar": "foo"
},
"metadata_merge_mode": "replace"
}
None known.
Response
location: /api/callouts/215
204 No Content
Contacts
Create a Contact
Request
curl "https://scfm.somleng.org/api/contacts" -d '{
"msisdn": "252662346012",
"metadata": {
"gender": "f",
"name": "Kate"
}
}' -X POST \
-H "Authorization: Bearer Qm-4pYdIlO0rpzmXLdQf5VJIdywh9afsPoFo0l49hkA"
Endpoint
POST /api/contacts
POST /api/contacts
Parameters
{
"msisdn": "252662346012",
"metadata": {
"gender": "f",
"name": "Kate"
}
}
Name | Description |
---|---|
msisdn required | Phone number in E.164 format |
Response
location: /api/contacts/221
201 Created
{
"id": 221,
"msisdn": "+252662346012",
"metadata": {
"gender": "f",
"name": "Kate"
},
"created_at": "2024-11-27T11:10:07.058Z",
"updated_at": "2024-11-27T11:10:07.058Z",
"account_id": 453
}
Create or update a Contact
Creates or updates a contact. If a contact is found with the msisdn
, it is updated, otherwise it is created.
Request
curl "https://scfm.somleng.org/api/contact_data" -d '{
"msisdn": "252662346016",
"metadata": {
"gender": "f",
"name": "Kate"
}
}' -X POST \
-H "Authorization: Bearer 3XrwudEhfGQ-Hmzp2i0ahKXJ4KtzX8J81ppWaLq5IqE"
Endpoint
POST /api/contact_data
POST /api/contact_data
Parameters
{
"msisdn": "252662346016",
"metadata": {
"gender": "f",
"name": "Kate"
}
}
None known.
Response
location: /api/contacts/225
201 Created
{
"id": 225,
"msisdn": "+252662346016",
"metadata": {
"gender": "f",
"name": "Kate"
},
"created_at": "2024-11-27T11:10:07.125Z",
"updated_at": "2024-11-27T11:10:07.125Z",
"account_id": 458
}
Delete a Contact
Request
curl "https://scfm.somleng.org/api/contacts/227" -d '' -X DELETE \
-H "Authorization: Bearer W-ot0QZ6gKAqGC-8p36JJ1ZX4bDIsR83xTWuN7u2JDc"
Endpoint
DELETE /api/contacts/:id
DELETE /api/contacts/227
Parameters
None known.
Response
location: /api/contacts
204 No Content
Filter contacts by metadata
Filters contacts by the metadata provided in the query.
Available operators: in, any, lt, lteq, gt, gteq, exists
Request
curl -g "https://scfm.somleng.org/api/contacts?q[metadata][registered_districts.any][]=1402&q[metadata][registered_districts.any][]=1401" -X GET \
-H "Authorization: Bearer OQ0yIrKZ23PUxqTP8h1RUP5nFVwGiqBTflai8jI_A_k"
Endpoint
GET /api/contacts
GET /api/contacts?q[metadata][registered_districts.any][]=1402&q[metadata][registered_districts.any][]=1401
Parameters
q: {"metadata"=>{"registered_districts.any"=>["1402", "1401"]}}
None known.
Response
per-page: 25
total: 1
200 OK
[
{
"id": 217,
"msisdn": "+252662346008",
"metadata": {
"registered_districts": [
"1401"
]
},
"created_at": "2024-11-27T11:10:07.016Z",
"updated_at": "2024-11-27T11:10:07.016Z",
"account_id": 451
}
]
List all Contacts
Request
curl -g "https://scfm.somleng.org/api/contacts" -X GET \
-H "Authorization: Bearer T8MTnYlq1y56ufBgg390r3IiMUmKcHbXFk8JcB6S1GI"
Endpoint
GET /api/contacts
GET /api/contacts
Parameters
None known.
Response
per-page: 25
total: 1
200 OK
[
{
"id": 215,
"msisdn": "+252662346006",
"metadata": {},
"created_at": "2024-11-27T11:10:06.994Z",
"updated_at": "2024-11-27T11:10:06.994Z",
"account_id": 449
}
]
Retrieve a Contact
Request
curl -g "https://scfm.somleng.org/api/contacts/222" -X GET \
-H "Authorization: Bearer 78c5eZQrTSvqx-fBUuQu24V0hcJuU6Z223fBV5CVvYE"
Endpoint
GET /api/contacts/:id
GET /api/contacts/222
Parameters
None known.
Response
location: /api/contacts/222
200 OK
{
"id": 222,
"msisdn": "+252662346013",
"metadata": {},
"created_at": "2024-11-27T11:10:07.077Z",
"updated_at": "2024-11-27T11:10:07.077Z",
"account_id": 455
}
Update a Contact
Request
curl "https://scfm.somleng.org/api/contacts/223" -d '{
"metadata": {
"bar": "foo"
},
"metadata_merge_mode": "replace"
}' -X PATCH \
-H "Authorization: Bearer fTHyQF9RB20lLb05wCm4C4O-tQfrAUBP5B-fQ3o7BRw"
Endpoint
PATCH /api/contacts/:id
PATCH /api/contacts/223
Parameters
{
"metadata": {
"bar": "foo"
},
"metadata_merge_mode": "replace"
}
None known.
Response
location: /api/contacts/223
204 No Content
Phone Calls
List all Phone Calls
Request
curl -g "https://scfm.somleng.org/api/phone_calls?q[metadata][foo]=bar" -X GET \
-H "Authorization: Bearer tYNtzbw3prTd06eTvRQGURfTaeBnZlaY0gMISWSoSsA"
Endpoint
GET /api/phone_calls
GET /api/phone_calls?q[metadata][foo]=bar
Parameters
q: {"metadata"=>{"foo"=>"bar"}}
None known.
Response
per-page: 25
total: 1
200 OK
[
{
"id": 148,
"callout_participation_id": 175,
"contact_id": 230,
"status": "created",
"msisdn": "+252662346021",
"remote_call_id": "da5b18ab-fec4-4ed1-b945-5323a055f77c",
"remote_status": null,
"remote_direction": null,
"remote_error_message": null,
"metadata": {
"foo": "bar"
},
"remote_response": {},
"remote_queue_response": {},
"call_flow_logic": "CallFlowLogic::HelloWorld",
"remotely_queued_at": null,
"created_at": "2024-11-27T11:10:07.196Z",
"updated_at": "2024-11-27T11:10:07.196Z",
"duration": 0,
"lock_version": 0,
"account_id": 462,
"remote_status_fetch_queued_at": null,
"callout_id": 223
}
]
Retrieve a Phone Call
Request
curl -g "https://scfm.somleng.org/api/phone_calls/157" -X GET \
-H "Authorization: Bearer SEM2uxa7xva4S2zSGTQLZ2E0lqAucqFpnMK_pdZn_1Y"
Endpoint
GET /api/phone_calls/:id
GET /api/phone_calls/157
Parameters
None known.
Response
location: /api/phone_calls/157
200 OK
{
"id": 157,
"callout_participation_id": 184,
"contact_id": 239,
"status": "created",
"msisdn": "+252662346030",
"remote_call_id": "894fa1ea-0749-43b8-a2f5-cf3100e2ca8b",
"remote_status": null,
"remote_direction": null,
"remote_error_message": null,
"metadata": {},
"remote_response": {},
"remote_queue_response": {},
"call_flow_logic": "CallFlowLogic::HelloWorld",
"remotely_queued_at": null,
"created_at": "2024-11-27T11:10:07.359Z",
"updated_at": "2024-11-27T11:10:07.359Z",
"duration": 0,
"lock_version": 0,
"account_id": 468,
"remote_status_fetch_queued_at": null,
"callout_id": 232
}
Recordings
List Recordings
Request
curl -g "https://scfm.somleng.org/api/recordings?q[created_at_or_after]=2024-11-27T11%3A10%3A07Z" -X GET \
-H "Authorization: Bearer 3i9t9esjyL6jHWYM0xz3OdoDQdZUKxpEKXOa41TECsI"
Endpoint
GET /api/recordings
GET /api/recordings?q[created_at_or_after]=2024-11-27T11%3A10%3A07Z
Parameters
q: {"created_at_or_after"=>"2024-11-27T11:10:07Z"}
None known.
Response
per-page: 25
total: 1
200 OK
[
{
"id": 1,
"phone_call_id": 158,
"account_id": 469,
"contact_id": 240,
"external_recording_id": "1495dfbf-21c3-47ef-a20f-a13a4adf9a32",
"external_recording_url": "https://api.somleng.org/2010-04-01/Accounts/bcca8205-1f7c-46f1-8fa7-9aadfe10c84b/Calls/e196d61b-f40e-40c7-beb9-16e6ea0a80a8/Recordings/1495dfbf-21c3-47ef-a20f-a13a4adf9a32",
"duration": 15,
"created_at": "2024-11-27T11:10:07.413Z",
"updated_at": "2024-11-27T11:10:07.419Z"
}
]
Retrieve a Recording
Request
curl -g "https://scfm.somleng.org/api/recordings/4" -X GET \
-H "Authorization: Bearer bzmvi0P-ZV6ku1Saoha6hZYmVELpRN2P5QKIMvpRE_8"
Endpoint
GET /api/recordings/:id
GET /api/recordings/4
Parameters
None known.
Response
location: /api/recordings/4
200 OK
{
"id": 4,
"phone_call_id": 161,
"account_id": 477,
"contact_id": 243,
"external_recording_id": "20e987e9-9138-42d0-bcd9-1b8549a2d17a",
"external_recording_url": "https://api.somleng.org/2010-04-01/Accounts/a8b41c56-d3ab-468b-b9db-804a13605eea/Calls/f27abe53-0576-464e-856a-0756d87b5afd/Recordings/20e987e9-9138-42d0-bcd9-1b8549a2d17a",
"duration": 15,
"created_at": "2024-11-27T11:10:07.534Z",
"updated_at": "2024-11-27T11:10:07.539Z"
}
Retrieve a recording as mp3
Request
curl -g "https://scfm.somleng.orgapi/recordings/5.mp3" -X GET \
-H "Authorization: Bearer 2ZWhIlZxWOisZn1UbANWrVMyVw5c8hBM3Ue2pUfPjs8"
Endpoint
GET api/recordings/:id.mp3
GET api/recordings/5.mp3
Parameters
None known.
Response
location: http://example.org/rails/active_storage/disk/eyJfcmFpbHMiOnsiZGF0YSI6eyJrZXkiOiJ5ZG1mM3pucXBlbzFrdjFmOG53ZjJ4Y2syemw3IiwiZGlzcG9zaXRpb24iOiJhdHRhY2htZW50OyBmaWxlbmFtZT1cInRlc3QubXAzXCI7IGZpbGVuYW1lKj1VVEYtOCcndGVzdC5tcDMiLCJjb250ZW50X3R5cGUiOiJhdWRpby9tcGVnIiwic2VydmljZV9uYW1lIjoidGVzdCJ9LCJleHAiOiIyMDI0LTExLTI3VDExOjE1OjA3LjU5NVoiLCJwdXIiOiJibG9iX2tleSJ9fQ==--919512be5181a349582013e486599426adbd6bad/test.mp3
302 Found
Remote Phone Call Events
Remote Phone Call Events are created by Somleng or Twilio Webhooks,
when an event happens in a Phone Call. Setup your Somleng or Twilio Webhook endpoint to point to
/api/remote_phone_call_events
List all Remote Phone Call Events
Request
curl -g "https://scfm.somleng.org/api/remote_phone_call_events?q[metadata][foo]=bar" -X GET \
-H "Authorization: Bearer YYKw1mPsPkox1H3YVqpQJ9TZ4kJsjhiV07mKzaYskjo"
Endpoint
GET /api/remote_phone_call_events
GET /api/remote_phone_call_events?q[metadata][foo]=bar
Parameters
q: {"metadata"=>{"foo"=>"bar"}}
None known.
Response
per-page: 25
total: 1
200 OK
[
{
"id": 78,
"phone_call_id": 163,
"details": {
"To": "345",
"From": "252662346037",
"CallSid": "9076aa8e-9392-4cc9-bbc1-c73630a4f5ad",
"Direction": "inbound",
"AccountSid": "e9909434-5b9d-4919-8c2f-ed0eeba3dc4d",
"ApiVersion": "2010-04-01",
"CallStatus": "completed"
},
"metadata": {
"foo": "bar"
},
"remote_call_id": "9076aa8e-9392-4cc9-bbc1-c73630a4f5ad",
"remote_direction": "inbound",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"created_at": "2024-11-27T11:10:07.612Z",
"updated_at": "2024-11-27T11:10:07.612Z",
"call_duration": 0
}
]
Retrieve a Remote Phone Call Event
Request
curl -g "https://scfm.somleng.org/api/remote_phone_call_events/89" -X GET \
-H "Authorization: Bearer szfqkBW7AuYe7K38PeuMebY92H2mRqMXRzH8oTmtgNw"
Endpoint
GET /api/remote_phone_call_events/:id
GET /api/remote_phone_call_events/89
Parameters
None known.
Response
location: /api/remote_phone_call_events/89
200 OK
{
"id": 89,
"phone_call_id": 174,
"details": {
"To": "345",
"From": "252662346059",
"CallSid": "25db3b22-1df2-46f9-8dcf-6e79470d8c49",
"Direction": "inbound",
"AccountSid": "75c1c938-2759-4416-afb3-78bd23c953f1",
"ApiVersion": "2010-04-01",
"CallStatus": "completed"
},
"metadata": {},
"remote_call_id": "25db3b22-1df2-46f9-8dcf-6e79470d8c49",
"remote_direction": "inbound",
"call_flow_logic": "CallFlowLogic::HelloWorld",
"created_at": "2024-11-27T11:10:07.811Z",
"updated_at": "2024-11-27T11:10:07.811Z",
"call_duration": 0
}
Update a Remote Phone Call Event
Request
curl "https://scfm.somleng.org/api/remote_phone_call_events/90" -d '{
"metadata": {
"foo": "bar"
},
"metadata_merge_mode": "replace"
}' -X PATCH \
-H "Authorization: Bearer lBEJ4swcg8-jaurUZwOMMRyvA7S4s6lgIX7HMiioWD0"
Endpoint
PATCH /api/remote_phone_call_events/:id
PATCH /api/remote_phone_call_events/90
Parameters
{
"metadata": {
"foo": "bar"
},
"metadata_merge_mode": "replace"
}
None known.
Response
location: /api/remote_phone_call_events/90
204 No Content
Shared API Features
Filtering, Sorting and Pagination
All index requests can be filtered and sorted by using the q
and sort
parameters.
Responses are paginated. The maxiumum number of items displayed for a single request is 25.
This can be verified by the Per-Page
response header. The actual number of items will appear in the Total
header.
If there are more than 25 items then you'll see a Link
header with links to the
first
, last
, next
and previous
pages.
The links are formatted according to RFC-8288.
Request
curl -g "https://scfm.somleng.org/api/contacts?q[metadata][gender]=f&q[metadata][date_of_birth.date.gt]=2022-01-01&q[metadata][date_of_birth.date.lt]=2022-02-01&q[created_at_after]=2024-11-26&sort=-id%2Ccreated_at" -X GET \
-H "Authorization: Bearer oXXPEXLrVc-IGq33TVt2l8kPMvJVnb1l5s8rhZyHpEg"
Endpoint
GET /api/contacts
GET /api/contacts?q[metadata][gender]=f&q[metadata][date_of_birth.date.gt]=2022-01-01&q[metadata][date_of_birth.date.lt]=2022-02-01&q[created_at_after]=2024-11-26&sort=-id%2Ccreated_at
Parameters
q: {"metadata"=>{"gender"=>"f", "date_of_birth.date.gt"=>"2022-01-01", "date_of_birth.date.lt"=>"2022-02-01"}, "created_at_after"=>"2024-11-26"}
sort: -id,created_at
Name | Description |
---|---|
q | A filter in which to filter resources. You can always filter by metadata , created_at and updated_at . Additional filters are available different resources |
sort | A comma separated list of sort columns. For example to sort by id in descending order, then by created_at in ascending order, specify sort: -id,created_at |
Response
per-page: 25
total: 26
200 OK
[
{
"id": 283,
"msisdn": "+252662346087",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.903Z",
"updated_at": "2024-11-27T11:10:07.903Z",
"account_id": 489
},
{
"id": 282,
"msisdn": "+252662346086",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.902Z",
"updated_at": "2024-11-27T11:10:07.902Z",
"account_id": 489
},
{
"id": 281,
"msisdn": "+252662346085",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.900Z",
"updated_at": "2024-11-27T11:10:07.900Z",
"account_id": 489
},
{
"id": 280,
"msisdn": "+252662346084",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.898Z",
"updated_at": "2024-11-27T11:10:07.898Z",
"account_id": 489
},
{
"id": 279,
"msisdn": "+252662346083",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.896Z",
"updated_at": "2024-11-27T11:10:07.896Z",
"account_id": 489
},
{
"id": 278,
"msisdn": "+252662346082",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.894Z",
"updated_at": "2024-11-27T11:10:07.894Z",
"account_id": 489
},
{
"id": 277,
"msisdn": "+252662346081",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.890Z",
"updated_at": "2024-11-27T11:10:07.890Z",
"account_id": 489
},
{
"id": 276,
"msisdn": "+252662346080",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.888Z",
"updated_at": "2024-11-27T11:10:07.888Z",
"account_id": 489
},
{
"id": 275,
"msisdn": "+252662346079",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.886Z",
"updated_at": "2024-11-27T11:10:07.886Z",
"account_id": 489
},
{
"id": 274,
"msisdn": "+252662346078",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.884Z",
"updated_at": "2024-11-27T11:10:07.884Z",
"account_id": 489
},
{
"id": 273,
"msisdn": "+252662346077",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.882Z",
"updated_at": "2024-11-27T11:10:07.882Z",
"account_id": 489
},
{
"id": 272,
"msisdn": "+252662346076",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.880Z",
"updated_at": "2024-11-27T11:10:07.880Z",
"account_id": 489
},
{
"id": 271,
"msisdn": "+252662346075",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.879Z",
"updated_at": "2024-11-27T11:10:07.879Z",
"account_id": 489
},
{
"id": 270,
"msisdn": "+252662346074",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.877Z",
"updated_at": "2024-11-27T11:10:07.877Z",
"account_id": 489
},
{
"id": 269,
"msisdn": "+252662346073",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.875Z",
"updated_at": "2024-11-27T11:10:07.875Z",
"account_id": 489
},
{
"id": 268,
"msisdn": "+252662346072",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.873Z",
"updated_at": "2024-11-27T11:10:07.873Z",
"account_id": 489
},
{
"id": 267,
"msisdn": "+252662346071",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.871Z",
"updated_at": "2024-11-27T11:10:07.871Z",
"account_id": 489
},
{
"id": 266,
"msisdn": "+252662346070",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.869Z",
"updated_at": "2024-11-27T11:10:07.869Z",
"account_id": 489
},
{
"id": 265,
"msisdn": "+252662346069",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.867Z",
"updated_at": "2024-11-27T11:10:07.867Z",
"account_id": 489
},
{
"id": 264,
"msisdn": "+252662346068",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.866Z",
"updated_at": "2024-11-27T11:10:07.866Z",
"account_id": 489
},
{
"id": 263,
"msisdn": "+252662346067",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.864Z",
"updated_at": "2024-11-27T11:10:07.864Z",
"account_id": 489
},
{
"id": 262,
"msisdn": "+252662346066",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.862Z",
"updated_at": "2024-11-27T11:10:07.862Z",
"account_id": 489
},
{
"id": 261,
"msisdn": "+252662346065",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.860Z",
"updated_at": "2024-11-27T11:10:07.860Z",
"account_id": 489
},
{
"id": 260,
"msisdn": "+252662346064",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.858Z",
"updated_at": "2024-11-27T11:10:07.858Z",
"account_id": 489
},
{
"id": 259,
"msisdn": "+252662346063",
"metadata": {
"gender": "f",
"date_of_birth": "2022-01-15"
},
"created_at": "2024-11-27T11:10:07.856Z",
"updated_at": "2024-11-27T11:10:07.856Z",
"account_id": 489
}
]
Metadata
Metadata is useful for storing additional,
structured information on an object.
As an example, you could store the contact's name and gender on the Contact
object.
Request
curl "https://scfm.somleng.org/api/contacts/285" -d '{
"metadata": {
"name": "Kate"
},
"metadata_merge_mode": "replace"
}' -X PATCH \
-H "Authorization: Bearer 9HUCa3zmMMcVGrjT9fUEhMlIsNMqOri2EDqK982PiWU"
Endpoint
PATCH /api/contacts/:id
PATCH /api/contacts/285
Parameters
{
"metadata": {
"name": "Kate"
},
"metadata_merge_mode": "replace"
}
Name | Description |
---|---|
metadata | Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. |
metadata_merge_mode | One of: merge (default), replace or deep_merge . merge merges the new metadata with the existing metadata. replace replaces the existing metadata with the new metadata. deep_merge deep merges the existing metadata with the new metadata. |
Response
location: /api/contacts/285
204 No Content
Users
Create a User
Request
curl "https://scfm.somleng.org/api/users" -d '{
"email": "user22@example.com",
"password": "secret123",
"metadata": {
"foo": "bar"
}
}' -X POST \
-H "Authorization: Bearer ECxNqWvvol6TN1E6G46Vc_p0EVEyo9vCUqzuBkwymww"
Endpoint
POST /api/users
POST /api/users
Parameters
{
"email": "user22@example.com",
"password": "secret123",
"metadata": {
"foo": "bar"
}
}
Name | Description |
---|---|
email required | The email address of the user |
password required | The initial password of the user. The user can change their password when they log in. |
Response
location: /api/users/15
201 Created
{
"id": 15,
"account_id": 495,
"metadata": {
"foo": "bar"
},
"email": "user22@example.com",
"created_at": "2024-11-27T11:10:08.004Z",
"updated_at": "2024-11-27T11:10:08.004Z",
"locale": "en"
}
Create a User Event
Request
curl "https://scfm.somleng.org/api/users/20/user_events" -d '{
"event": "invite"
}' -X POST \
-H "Authorization: Bearer hayfoGRA-RRkqnqOchsAfIVNRU2cI6JKy3zDJwS2W_8"
Endpoint
POST /api/users/:user_id/user_events
POST /api/users/20/user_events
Parameters
{
"event": "invite"
}
Name | Description |
---|---|
event required | Only invite is supported at this time |
Response
location: /api/users/20
201 Created
{
"account_id": 501,
"id": 20,
"metadata": {},
"email": "user27@example.com",
"created_at": "2024-11-27T11:10:08.093Z",
"updated_at": "2024-11-27T11:10:08.100Z",
"locale": "en"
}
Delete a User
Request
curl "https://scfm.somleng.org/api/users/19" -d '' -X DELETE \
-H "Authorization: Bearer jwE_ChmG0rWvwbzuYN-drnfoixyqDOl3mNy4a2BDFtA"
Endpoint
DELETE /api/users/:id
DELETE /api/users/19
Parameters
None known.
Response
location: /api/users
204 No Content
List all Users
Request
curl -g "https://scfm.somleng.org/api/users?q[metadata][foo]=bar" -X GET \
-H "Authorization: Bearer wB2uxL2RuA8e0kaH-cZuxgJOM4xdNoPBFT0QU2NSdzk"
Endpoint
GET /api/users
GET /api/users?q[metadata][foo]=bar
Parameters
q: {"metadata"=>{"foo"=>"bar"}}
None known.
Response
per-page: 25
total: 1
200 OK
[
{
"id": 10,
"account_id": 491,
"metadata": {
"foo": "bar"
},
"email": "user17@example.com",
"created_at": "2024-11-27T11:10:07.945Z",
"updated_at": "2024-11-27T11:10:07.945Z",
"locale": "en"
}
]
Retrieve a User
Request
curl -g "https://scfm.somleng.org/api/users/17" -X GET \
-H "Authorization: Bearer ObJyNtTaaUIoV7s-OMbsrjsz80UV0kHTT7xQMy9uNOk"
Endpoint
GET /api/users/:id
GET /api/users/17
Parameters
None known.
Response
location: /api/users/17
200 OK
{
"id": 17,
"account_id": 498,
"metadata": {},
"email": "user24@example.com",
"created_at": "2024-11-27T11:10:08.035Z",
"updated_at": "2024-11-27T11:10:08.035Z",
"locale": "en"
}
Update a User
Request
curl "https://scfm.somleng.org/api/users/18" -d '{
"metadata": {
"bar": "foo"
},
"metadata_merge_mode": "replace"
}' -X PATCH \
-H "Authorization: Bearer b7f-PAMHMNOy3m69OzgycSET8gdNHm-Zr1fdAyLxaSE"
Endpoint
PATCH /api/users/:id
PATCH /api/users/18
Parameters
{
"metadata": {
"bar": "foo"
},
"metadata_merge_mode": "replace"
}
None known.
Response
location: /api/users/18
204 No Content