NAV
cURL

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 5qGF-da8ADuisdg2ksMMDkQ5KcINmXewRSOkl2L-CAI"

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

Response

Location: /api/access_tokens/16
201 Created
{
  "id": 16,
  "token": "E-MgHJoo8V1j-aJKxEgdQcm7jEUrIv69hS9r82DxI2M",
  "created_at": "2022-08-10T03:11:38.425Z",
  "updated_at": "2022-08-10T03:11:38.427Z",
  "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 XaUF84BTdBMOgqxQ3hTttZtLdi6jrgXjSvUUWk0tUfk"

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 5W1m3yl-RO0-nfevNjHi5KhMOwFMdwSB98ICaV6YaLA"

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": "QCSWknlGBkeT_soXWVpxrEwkY9_xZHw3tbIHCYWbmeQ",
    "created_at": "2022-08-10T03:11:38.321Z",
    "updated_at": "2022-08-10T03:11:38.322Z",
    "metadata": {
      "foo": "bar"
    },
    "permissions": [

    ]
  }
]

Retrieve an Access Token

Request

curl -g "https://scfm.somleng.org/api/access_tokens/19" -X GET \
    -H "Authorization: Bearer awvt9tOzmX7H14suYyXHkpaQtvpUe8Lv3hucuOXmixs"

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": "awvt9tOzmX7H14suYyXHkpaQtvpUe8Lv3hucuOXmixs",
  "created_at": "2022-08-10T03:11:38.466Z",
  "updated_at": "2022-08-10T03:11:38.467Z",
  "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 f7M96Zo5ZZ6Jpz4tXzGGLOjTYra_pqbsV4w32K5LeEQ"

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 gIzg6ZRr-qFTUgTb_Tki3rFc7w8UpxNYXZCTDuTwj5o"

Endpoint

GET /api/account

GET /api/account

Parameters

None known.

Response

Location: /api/accounts/363
200 OK
{
  "id": 363,
  "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": "2022-08-10T03:11:38.556Z",
  "updated_at": "2022-08-10T03:11:38.556Z",
  "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 7Nd7bQZw6SM4PrxNtMEfl3fj80iGr9xj_xllidehQTg"

Endpoint

PATCH /api/account

PATCH /api/account

Parameters

{
  "metadata": {
    "foo": "bar"
  },
  "metadata_merge_mode": "replace"
}

None known.

Response

Location: /api/accounts/364
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 _yl5RhhXcySKhe4d3AWeY1QF64Z7ak0G_rWmjh_ZNbk"

Endpoint

POST /api/accounts

POST /api/accounts

Parameters

None known.

Response

Location: /api/accounts/369
201 Created
{
  "id": 369,
  "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": "2022-08-10T03:11:38.649Z",
  "updated_at": "2022-08-10T03:11:38.649Z",
  "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/374" -d '' -X DELETE \
    -H "Authorization: Bearer qf6wAz_7mIObBE1bT_AhxRBlZKINZTGjwmoN1JoUcII"

Endpoint

DELETE /api/accounts/:id

DELETE /api/accounts/374

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 aq0j3WOjW3Q6rwSdu5yz7HDJ546o_UhYtNfyRYXHqNM"

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": 365,
    "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": "2022-08-10T03:11:38.598Z",
    "updated_at": "2022-08-10T03:11:38.598Z",
    "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/370" -X GET \
    -H "Authorization: Bearer -NyveLLBQb5hdpYwJn64jk4xGIBOR6HjIYHHb9FkS8o"

Endpoint

GET /api/accounts/:id

GET /api/accounts/370

Parameters

None known.

Response

Location: /api/accounts/370
200 OK
{
  "id": 370,
  "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": "2022-08-10T03:11:38.656Z",
  "updated_at": "2022-08-10T03:11:38.656Z",
  "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/372" -d '{
  "metadata": {
    "foo": "bar"
  },
  "metadata_merge_mode": "replace",
  "twilio_account_sid": "AC8",
  "somleng_account_sid": "0144d73f-1287-4004-8a9d-7f7dc2c5a2dd",
  "twilio_auth_token": "9c1a5b50-f258-4962-be66-2de69b21e794",
  "somleng_auth_token": "20509908-33d9-40d5-8bd3-a23dadbfa6d2",
  "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 K-178goiqrsfNSHEZAnPaTsa1l9Hoi-elTu9pUaFOHk"

Endpoint

PATCH /api/accounts/:id

PATCH /api/accounts/372

Parameters

{
  "metadata": {
    "foo": "bar"
  },
  "metadata_merge_mode": "replace",
  "twilio_account_sid": "AC8",
  "somleng_account_sid": "0144d73f-1287-4004-8a9d-7f7dc2c5a2dd",
  "twilio_auth_token": "9c1a5b50-f258-4962-be66-2de69b21e794",
  "somleng_auth_token": "20509908-33d9-40d5-8bd3-a23dadbfa6d2",
  "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/372
204 No Content

Batch Operations

Create a Batch Operation Event

Request

curl "https://scfm.somleng.org/api/batch_operations/36/batch_operation_events" -d '{
  "event": "queue"
}' -X POST \
    -H "Authorization: Bearer 5HJC_Y3bs1FxdY7J_w-MPCPtlLHFtYqVg60fQF8CR0k"

Endpoint

POST /api/batch_operations/:batch_operation_id/batch_operation_events

POST /api/batch_operations/36/batch_operation_events

Parameters

{
  "event": "queue"
}
Name Description
event required Either queue or requeue.

Response

Location: /api/batch_operations/36
201 Created
{
  "id": 36,
  "callout_id": 181,
  "parameters": {
  },
  "metadata": {
  },
  "status": "queued",
  "created_at": "2022-08-10T03:11:39.021Z",
  "updated_at": "2022-08-10T03:11:39.021Z",
  "account_id": 389,
  "type": "BatchOperation::CalloutPopulation"
}

Delete a Batch Operation

Request

curl "https://scfm.somleng.org/api/batch_operations/34" -d '' -X DELETE \
    -H "Authorization: Bearer QLuFwv3KcJcSj996Qd8NxvnHPTJMlzE9RPfZExBguWI"

Endpoint

DELETE /api/batch_operations/:id

DELETE /api/batch_operations/34

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]=171" -X GET \
    -H "Authorization: Bearer Dy2qGacJ3qURynHbgkTxfdt2R4QEX1RCev5s6aVmkCU"

Endpoint

GET /api/batch_operations

GET /api/batch_operations?q[callout_id]=171

Parameters

q: {"callout_id"=>"171"}

None known.

Response

Per-Page: 25
Total: 1
200 OK
[
  {
    "id": 28,
    "callout_id": 171,
    "parameters": {
    },
    "metadata": {
    },
    "status": "preview",
    "created_at": "2022-08-10T03:11:38.775Z",
    "updated_at": "2022-08-10T03:11:38.775Z",
    "account_id": 378,
    "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": 174,
  "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"
      }
    }
  },
  "type": "BatchOperation::CalloutPopulation"
}' -X POST \
    -H "Authorization: Bearer 7pa8o14B8x_AczbJXaqkdXgYc-ZF5ciXTDiATFPzDps"

Endpoint

POST /api/batch_operations

POST /api/batch_operations

Parameters

{
  "callout_id": 174,
  "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"
      }
    }
  },
  "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/31
201 Created
{
  "id": 31,
  "callout_id": 174,
  "parameters": {
    "contact_filter_params": {
      "metadata": {
        "gender": "f",
        "date_of_birth.date.gteq": "2022-01-01",
        "date_of_birth.date.lt": "2022-02-01"
      }
    }
  },
  "metadata": {
    "foo": "bar"
  },
  "status": "preview",
  "created_at": "2022-08-10T03:11:38.828Z",
  "updated_at": "2022-08-10T03:11:38.828Z",
  "account_id": 380,
  "type": "BatchOperation::CalloutPopulation"
}

Retrieve a Batch Operation

Request

curl -g "https://scfm.somleng.org/api/batch_operations/32" -X GET \
    -H "Authorization: Bearer I9wekV5dbXQorFjr15yDzF79Wctgqc7o-mX67v8NydM"

Endpoint

GET /api/batch_operations/:id

GET /api/batch_operations/32

Parameters

None known.

Response

Location: /api/batch_operations/32
200 OK
{
  "id": 32,
  "callout_id": 176,
  "parameters": {
  },
  "metadata": {
  },
  "status": "preview",
  "created_at": "2022-08-10T03:11:38.890Z",
  "updated_at": "2022-08-10T03:11:38.890Z",
  "account_id": 383,
  "type": "BatchOperation::CalloutPopulation"
}

Update a Batch Operation

Request

curl "https://scfm.somleng.org/api/batch_operations/33" -d '{
  "metadata": {
    "foo": "bar",
    "bar": "foo"
  },
  "parameters": {
    "contact_filter_params": {
      "metadata": {
        "foo": "bar"
      }
    }
  },
  "metadata_merge_mode": "replace"
}' -X PATCH \
    -H "Authorization: Bearer GzobMC2bFMvmb2tc9VyaBPbCDVJF4r8Qj2YXFsQESoQ"

Endpoint

PATCH /api/batch_operations/:id

PATCH /api/batch_operations/33

Parameters

{
  "metadata": {
    "foo": "bar",
    "bar": "foo"
  },
  "parameters": {
    "contact_filter_params": {
      "metadata": {
        "foo": "bar"
      }
    }
  },
  "metadata_merge_mode": "replace"
}

None known.

Response

Location: /api/batch_operations/33
204 No Content

Callout Participations

Create a Callout Participation

Request

curl "https://scfm.somleng.org/api/callouts/191/callout_participations" -d '{
  "contact_id": 170,
  "msisdn": "252662345937",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
    "foo": "bar"
  }
}' -X POST \
    -H "Authorization: Bearer clVNUfCCffmhS1pb0Wic8eRvHLN0RJqxBjSdFp0agg4"

Endpoint

POST /api/callouts/:callout_id/callout_participations

POST /api/callouts/191/callout_participations

Parameters

{
  "contact_id": 170,
  "msisdn": "252662345937",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
    "foo": "bar"
  }
}

None known.

Response

Location: /api/callout_participations/145
201 Created
{
  "id": 145,
  "callout_id": 191,
  "contact_id": 170,
  "callout_population_id": null,
  "msisdn": "+252662345937",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
    "foo": "bar"
  },
  "created_at": "2022-08-10T03:11:39.288Z",
  "updated_at": "2022-08-10T03:11:39.288Z",
  "answered": false,
  "phone_calls_count": 0
}

Create a Callout Participation with invalid data

Request

curl "https://scfm.somleng.org/api/callouts/192/callout_participations" -d '' -X POST \
    -H "Authorization: Bearer w8cJ3J3rJloit0uqGkCn7IDhRCazqk0R6PpzsXL-egM"

Endpoint

POST /api/callouts/:callout_id/callout_participations

POST /api/callouts/192/callout_participations

Parameters

None known.

Response


422 Unprocessable Entity
{
  "errors": {
    "msisdn": [
      "can't be blank"
    ],
    "contact": [
      "must exist"
    ]
  }
}

Delete a Callout Participation

Request

curl "https://scfm.somleng.org/api/callout_participations/148" -d '' -X DELETE \
    -H "Authorization: Bearer Nrno-fLrBxZXp6At5CZbZFfNq4iiXlqZYnEro3vEMeo"

Endpoint

DELETE /api/callout_participations/:id

DELETE /api/callout_participations/148

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/149" -d '' -X DELETE \
    -H "Authorization: Bearer StUK8nZKYoQwegjw9mSfc5FNtRlxxxDskDurinfxHd4"

Endpoint

DELETE /api/callout_participations/:id

DELETE /api/callout_participations/149

Parameters

None known.

Response


422 Unprocessable Entity
{
  "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 ly694mN_voD3Lj8iFCjBVmnAe9xl9WrmF7gWSQoMexU"

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": 138,
    "callout_id": 184,
    "contact_id": 163,
    "callout_population_id": null,
    "msisdn": "+252662345929",
    "call_flow_logic": "CallFlowLogic::HelloWorld",
    "metadata": {
      "foo": "bar"
    },
    "created_at": "2022-08-10T03:11:39.143Z",
    "updated_at": "2022-08-10T03:11:39.143Z",
    "answered": false,
    "phone_calls_count": 0
  }
]

Retrieve a Callout Participation

Request

curl -g "https://scfm.somleng.org/api/callout_participations/146" -X GET \
    -H "Authorization: Bearer 1ndzO7lnjZOP_0uzeUpsL3K9oDyLfMulIeVKbJD5Wm8"

Endpoint

GET /api/callout_participations/:id

GET /api/callout_participations/146

Parameters

None known.

Response

Location: /api/callout_participations/146
200 OK
{
  "id": 146,
  "callout_id": 193,
  "contact_id": 171,
  "callout_population_id": null,
  "msisdn": "+252662345938",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
  },
  "created_at": "2022-08-10T03:11:39.353Z",
  "updated_at": "2022-08-10T03:11:39.353Z",
  "answered": false,
  "phone_calls_count": 0
}

Update a Callout Participation

Request

curl "https://scfm.somleng.org/api/callout_participations/147" -d '{
  "contact_id": 173,
  "msisdn": "252662345941",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
    "bar": "foo"
  },
  "metadata_merge_mode": "replace"
}' -X PATCH \
    -H "Authorization: Bearer dL7CuWMva8vB-jToGF7vBJE9zOTptXgCwd8BAV6BLms"

Endpoint

PATCH /api/callout_participations/:id

PATCH /api/callout_participations/147

Parameters

{
  "contact_id": 173,
  "msisdn": "252662345941",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
    "bar": "foo"
  },
  "metadata_merge_mode": "replace"
}

None known.

Response

Location: /api/callout_participations/147
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 DF2r4_8aZGM5HnJih_W1CA6Nyd_sfiB7s_IfY_7eB5g"

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/202
201 Created
{
  "id": 202,
  "status": "initialized",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
    "foo": "bar"
  },
  "created_at": "2022-08-10T03:11:39.638Z",
  "updated_at": "2022-08-10T03:11:39.638Z",
  "account_id": 406,
  "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/207/callout_events" -d '{
  "event": "start"
}' -X POST \
    -H "Authorization: Bearer EeBJlqH2oXMCUnMoDUY_K0f3kHdMKv2HajJIU2yu3PM"

Endpoint

POST /api/callouts/:callout_id/callout_events

POST /api/callouts/207/callout_events

Parameters

{
  "event": "start"
}
Name Description
event required One of: start, pause, resume, stop

Response

Location: /api/callouts/207
201 Created
{
  "account_id": 411,
  "id": 207,
  "status": "running",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
  },
  "created_at": "2022-08-10T03:11:39.787Z",
  "updated_at": "2022-08-10T03:11:39.804Z",
  "audio_url": null,
  "settings": {
  },
  "created_by_id": null
}

Delete a Callout

Request

curl "https://scfm.somleng.org/api/callouts/205" -d '' -X DELETE \
    -H "Authorization: Bearer ufIU48YLJNAMWqmRC6Jz8B4QNWjx_X2zzUYs8pXPavE"

Endpoint

DELETE /api/callouts/:id

DELETE /api/callouts/205

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 SSEFsls6k771QKGQlYvamI7VPKoj2SN9_DGB9-aHoTE"

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": 197,
    "status": "initialized",
    "call_flow_logic": "CallFlowLogic::HelloWorld",
    "metadata": {
      "foo": "bar"
    },
    "created_at": "2022-08-10T03:11:39.521Z",
    "updated_at": "2022-08-10T03:11:39.521Z",
    "account_id": 403,
    "audio_url": null,
    "settings": {
    },
    "created_by_id": null
  }
]

Retrieve a Callout

Request

curl -g "https://scfm.somleng.org/api/callouts/203" -X GET \
    -H "Authorization: Bearer AgN5gPvFfPoZXxKe1BxDpdyrby6ZlgGDqN4dyy1scEo"

Endpoint

GET /api/callouts/:id

GET /api/callouts/203

Parameters

None known.

Response

Location: /api/callouts/203
200 OK
{
  "id": 203,
  "status": "initialized",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
  },
  "created_at": "2022-08-10T03:11:39.657Z",
  "updated_at": "2022-08-10T03:11:39.657Z",
  "account_id": 407,
  "audio_url": null,
  "settings": {
  },
  "created_by_id": null
}

Update a Callout

Request

curl "https://scfm.somleng.org/api/callouts/204" -d '{
  "metadata": {
    "bar": "foo"
  },
  "metadata_merge_mode": "replace"
}' -X PATCH \
    -H "Authorization: Bearer 98Zyr6qwXmwhnzaQGa4QuERySvqquzpRI1UtzCORm3Y"

Endpoint

PATCH /api/callouts/:id

PATCH /api/callouts/204

Parameters

{
  "metadata": {
    "bar": "foo"
  },
  "metadata_merge_mode": "replace"
}

None known.

Response

Location: /api/callouts/204
204 No Content

Contacts

Create a Contact

Request

curl "https://scfm.somleng.org/api/contacts" -d '{
  "msisdn": "252662345951",
  "metadata": {
    "gender": "f",
    "name": "Kate"
  }
}' -X POST \
    -H "Authorization: Bearer fJUoOpdYDGevQEAMRBA_fY0iGvDwxM185ZO7PO6PlHU"

Endpoint

POST /api/contacts

POST /api/contacts

Parameters

{
  "msisdn": "252662345951",
  "metadata": {
    "gender": "f",
    "name": "Kate"
  }
}
Name Description
msisdn required Phone number in E.164 format

Response

Location: /api/contacts/183
201 Created
{
  "id": 183,
  "msisdn": "+252662345951",
  "metadata": {
    "gender": "f",
    "name": "Kate"
  },
  "created_at": "2022-08-10T03:11:39.929Z",
  "updated_at": "2022-08-10T03:11:39.929Z",
  "account_id": 417
}

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": "252662345955",
  "metadata": {
    "gender": "f",
    "name": "Kate"
  }
}' -X POST \
    -H "Authorization: Bearer xcV4bc0IU7fe13-ZExbNYprWeOQn4as2W3GdKHxL2Ks"

Endpoint

POST /api/contact_data

POST /api/contact_data

Parameters

{
  "msisdn": "252662345955",
  "metadata": {
    "gender": "f",
    "name": "Kate"
  }
}

None known.

Response

Location: /api/contacts/187
201 Created
{
  "id": 187,
  "msisdn": "+252662345955",
  "metadata": {
    "gender": "f",
    "name": "Kate"
  },
  "created_at": "2022-08-10T03:11:40.033Z",
  "updated_at": "2022-08-10T03:11:40.033Z",
  "account_id": 422
}

Delete a Contact

Request

curl "https://scfm.somleng.org/api/contacts/189" -d '' -X DELETE \
    -H "Authorization: Bearer cRCLBQi1Q4ZNTEOsIeRP86s0152ocNhpOKWQ6oy4onA"

Endpoint

DELETE /api/contacts/:id

DELETE /api/contacts/189

Parameters

None known.

Response

Location: /api/contacts
204 No Content

List all Contacts

Request

curl -g "https://scfm.somleng.org/api/contacts?q[metadata][foo]=bar" -X GET \
    -H "Authorization: Bearer ZnIv7YRmSeL6b2O3CimH_JzS3nENeCU65RJ3fvOt7hA"

Endpoint

GET /api/contacts

GET /api/contacts?q[metadata][foo]=bar

Parameters

q: {"metadata"=>{"foo"=>"bar"}}

None known.

Response

Per-Page: 25
Total: 1
200 OK
[
  {
    "id": 178,
    "msisdn": "+252662345946",
    "metadata": {
      "foo": "bar"
    },
    "created_at": "2022-08-10T03:11:39.858Z",
    "updated_at": "2022-08-10T03:11:39.858Z",
    "account_id": 414
  }
]

Retrieve a Contact

Request

curl -g "https://scfm.somleng.org/api/contacts/184" -X GET \
    -H "Authorization: Bearer HqxLctKZSVxKX4TCAdqDFtFau4kslToRCiJxMLJaCcE"

Endpoint

GET /api/contacts/:id

GET /api/contacts/184

Parameters

None known.

Response

Location: /api/contacts/184
200 OK
{
  "id": 184,
  "msisdn": "+252662345952",
  "metadata": {
  },
  "created_at": "2022-08-10T03:11:39.954Z",
  "updated_at": "2022-08-10T03:11:39.954Z",
  "account_id": 419
}

Update a Contact

Request

curl "https://scfm.somleng.org/api/contacts/185" -d '{
  "metadata": {
    "bar": "foo"
  },
  "metadata_merge_mode": "replace"
}' -X PATCH \
    -H "Authorization: Bearer J_NMk1SMXlC5f7pRUKM8FrKwXMvyUKzPp9xJgqHisgI"

Endpoint

PATCH /api/contacts/:id

PATCH /api/contacts/185

Parameters

{
  "metadata": {
    "bar": "foo"
  },
  "metadata_merge_mode": "replace"
}

None known.

Response

Location: /api/contacts/185
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 ILNWs0bpuwHMEPCQ2TILVlTe4UGRJ4mzp67ZnA3oxyc"

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": 124,
    "callout_participation_id": 154,
    "contact_id": 192,
    "status": "created",
    "msisdn": "+252662345960",
    "remote_call_id": "52342bb2-cd8a-4baa-84c0-fc0d8ebd60d1",
    "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": "2022-08-10T03:11:40.136Z",
    "updated_at": "2022-08-10T03:11:40.136Z",
    "duration": 0,
    "lock_version": 0,
    "account_id": 426,
    "remote_status_fetch_queued_at": null,
    "callout_id": 212
  }
]

Retrieve a Phone Call

Request

curl -g "https://scfm.somleng.org/api/phone_calls/133" -X GET \
    -H "Authorization: Bearer Hyxf3FSlUZSrMJCrCjrWHheI_JRoxlpQRoal_-2llIg"

Endpoint

GET /api/phone_calls/:id

GET /api/phone_calls/133

Parameters

None known.

Response

Location: /api/phone_calls/133
200 OK
{
  "id": 133,
  "callout_participation_id": 163,
  "contact_id": 201,
  "status": "created",
  "msisdn": "+252662345969",
  "remote_call_id": "c18c58a6-e9f0-4feb-9d8b-31e8cf8c3dc0",
  "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": "2022-08-10T03:11:40.343Z",
  "updated_at": "2022-08-10T03:11:40.343Z",
  "duration": 0,
  "lock_version": 0,
  "account_id": 432,
  "remote_status_fetch_queued_at": null,
  "callout_id": 221
}

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 FRPY5j0K0FTQZREffMZHOZGPmczBO6_7QHNoPmaDlUA"

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": 56,
    "phone_call_id": 134,
    "details": {
      "To": "345",
      "From": "252662345971",
      "CallSid": "93dbcad3-bbad-44e4-8be8-ffb0d0444d92",
      "Direction": "inbound",
      "AccountSid": "f7de85cc-2e79-4ce2-bfb4-1eb1b5ba8b50",
      "ApiVersion": "2010-04-01",
      "CallStatus": "completed"
    },
    "metadata": {
      "foo": "bar"
    },
    "remote_call_id": "93dbcad3-bbad-44e4-8be8-ffb0d0444d92",
    "remote_direction": "inbound",
    "call_flow_logic": "CallFlowLogic::HelloWorld",
    "created_at": "2022-08-10T03:11:40.378Z",
    "updated_at": "2022-08-10T03:11:40.378Z",
    "call_duration": 0
  }
]

Retrieve a Remote Phone Call Event

Request

curl -g "https://scfm.somleng.org/api/remote_phone_call_events/67" -X GET \
    -H "Authorization: Bearer BBPrm1JrY1koVVIzeChMFkpXVA93wL-IgeSx8mnyPq0"

Endpoint

GET /api/remote_phone_call_events/:id

GET /api/remote_phone_call_events/67

Parameters

None known.

Response

Location: /api/remote_phone_call_events/67
200 OK
{
  "id": 67,
  "phone_call_id": 145,
  "details": {
    "To": "345",
    "From": "252662345993",
    "CallSid": "e04adeef-275c-45e5-85e1-ec927dd4b909",
    "Direction": "inbound",
    "AccountSid": "dbedafee-e2b7-4ae1-a592-cb4756a7294a",
    "ApiVersion": "2010-04-01",
    "CallStatus": "completed"
  },
  "metadata": {
  },
  "remote_call_id": "e04adeef-275c-45e5-85e1-ec927dd4b909",
  "remote_direction": "inbound",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "created_at": "2022-08-10T03:11:40.656Z",
  "updated_at": "2022-08-10T03:11:40.656Z",
  "call_duration": 0
}

Update a Remote Phone Call Event

Request

curl "https://scfm.somleng.org/api/remote_phone_call_events/68" -d '{
  "metadata": {
    "foo": "bar"
  },
  "metadata_merge_mode": "replace"
}' -X PATCH \
    -H "Authorization: Bearer D_KcxRsEGGJaKRPg0u9x4jgu78mP4PSzr-hopewUX4o"

Endpoint

PATCH /api/remote_phone_call_events/:id

PATCH /api/remote_phone_call_events/68

Parameters

{
  "metadata": {
    "foo": "bar"
  },
  "metadata_merge_mode": "replace"
}

None known.

Response

Location: /api/remote_phone_call_events/68
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]=2022-08-09&sort=-id%2Ccreated_at" -X GET \
    -H "Authorization: Bearer qQXDMVHlskg3EsXxKsMEnGRH0fNmspPm773MwHzbQQ0"

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]=2022-08-09&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"=>"2022-08-09"}
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": 243,
    "msisdn": "+252662346022",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.896Z",
    "updated_at": "2022-08-10T03:11:40.896Z",
    "account_id": 446
  },
  {
    "id": 242,
    "msisdn": "+252662346021",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.893Z",
    "updated_at": "2022-08-10T03:11:40.893Z",
    "account_id": 446
  },
  {
    "id": 241,
    "msisdn": "+252662346020",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.891Z",
    "updated_at": "2022-08-10T03:11:40.891Z",
    "account_id": 446
  },
  {
    "id": 240,
    "msisdn": "+252662346019",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.889Z",
    "updated_at": "2022-08-10T03:11:40.889Z",
    "account_id": 446
  },
  {
    "id": 239,
    "msisdn": "+252662346018",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.887Z",
    "updated_at": "2022-08-10T03:11:40.887Z",
    "account_id": 446
  },
  {
    "id": 238,
    "msisdn": "+252662346017",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.885Z",
    "updated_at": "2022-08-10T03:11:40.885Z",
    "account_id": 446
  },
  {
    "id": 237,
    "msisdn": "+252662346016",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.882Z",
    "updated_at": "2022-08-10T03:11:40.882Z",
    "account_id": 446
  },
  {
    "id": 236,
    "msisdn": "+252662346015",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.880Z",
    "updated_at": "2022-08-10T03:11:40.880Z",
    "account_id": 446
  },
  {
    "id": 235,
    "msisdn": "+252662346014",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.878Z",
    "updated_at": "2022-08-10T03:11:40.878Z",
    "account_id": 446
  },
  {
    "id": 234,
    "msisdn": "+252662346013",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.876Z",
    "updated_at": "2022-08-10T03:11:40.876Z",
    "account_id": 446
  },
  {
    "id": 233,
    "msisdn": "+252662346012",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.874Z",
    "updated_at": "2022-08-10T03:11:40.874Z",
    "account_id": 446
  },
  {
    "id": 232,
    "msisdn": "+252662346011",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.871Z",
    "updated_at": "2022-08-10T03:11:40.871Z",
    "account_id": 446
  },
  {
    "id": 231,
    "msisdn": "+252662346010",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.869Z",
    "updated_at": "2022-08-10T03:11:40.869Z",
    "account_id": 446
  },
  {
    "id": 230,
    "msisdn": "+252662346009",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.867Z",
    "updated_at": "2022-08-10T03:11:40.867Z",
    "account_id": 446
  },
  {
    "id": 229,
    "msisdn": "+252662346008",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.865Z",
    "updated_at": "2022-08-10T03:11:40.865Z",
    "account_id": 446
  },
  {
    "id": 228,
    "msisdn": "+252662346007",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.863Z",
    "updated_at": "2022-08-10T03:11:40.863Z",
    "account_id": 446
  },
  {
    "id": 227,
    "msisdn": "+252662346006",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.860Z",
    "updated_at": "2022-08-10T03:11:40.860Z",
    "account_id": 446
  },
  {
    "id": 226,
    "msisdn": "+252662346005",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.858Z",
    "updated_at": "2022-08-10T03:11:40.858Z",
    "account_id": 446
  },
  {
    "id": 225,
    "msisdn": "+252662346004",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.856Z",
    "updated_at": "2022-08-10T03:11:40.856Z",
    "account_id": 446
  },
  {
    "id": 224,
    "msisdn": "+252662346003",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.854Z",
    "updated_at": "2022-08-10T03:11:40.854Z",
    "account_id": 446
  },
  {
    "id": 223,
    "msisdn": "+252662346002",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.852Z",
    "updated_at": "2022-08-10T03:11:40.852Z",
    "account_id": 446
  },
  {
    "id": 222,
    "msisdn": "+252662346001",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.850Z",
    "updated_at": "2022-08-10T03:11:40.850Z",
    "account_id": 446
  },
  {
    "id": 221,
    "msisdn": "+252662346000",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.847Z",
    "updated_at": "2022-08-10T03:11:40.847Z",
    "account_id": 446
  },
  {
    "id": 220,
    "msisdn": "+252662345999",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.845Z",
    "updated_at": "2022-08-10T03:11:40.845Z",
    "account_id": 446
  },
  {
    "id": 219,
    "msisdn": "+252662345998",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-10T03:11:40.843Z",
    "updated_at": "2022-08-10T03:11:40.843Z",
    "account_id": 446
  }
]

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/245" -d '{
  "metadata": {
    "name": "Kate"
  },
  "metadata_merge_mode": "replace"
}' -X PATCH \
    -H "Authorization: Bearer B4JZZtaD1Vy6ydhEb40ALGT2iof7kXBc1yTVhwUOl-E"

Endpoint

PATCH /api/contacts/:id

PATCH /api/contacts/245

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/245
204 No Content

Users

Create a User

Request

curl "https://scfm.somleng.org/api/users" -d '{
  "email": "user32@example.com",
  "password": "secret123",
  "metadata": {
    "foo": "bar"
  }
}' -X POST \
    -H "Authorization: Bearer 7iSOjOlHxpH7BXAlJQbrfmllc81WIC_LfSeoYRlGWbs"

Endpoint

POST /api/users

POST /api/users

Parameters

{
  "email": "user32@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/25
201 Created
{
  "id": 25,
  "account_id": 452,
  "metadata": {
    "foo": "bar"
  },
  "email": "user32@example.com",
  "created_at": "2022-08-10T03:11:41.037Z",
  "updated_at": "2022-08-10T03:11:41.037Z",
  "locale": "en"
}

Create a User Event

Request

curl "https://scfm.somleng.org/api/users/30/user_events" -d '{
  "event": "invite"
}' -X POST \
    -H "Authorization: Bearer 1qp_G_HoSOziha133XSkDYqik7Q4hKeIIz1HGSPzYy0"

Endpoint

POST /api/users/:user_id/user_events

POST /api/users/30/user_events

Parameters

{
  "event": "invite"
}
Name Description
event required Only invite is supported at this time

Response

Location: /api/users/30
201 Created
{
  "account_id": 458,
  "id": 30,
  "metadata": {
  },
  "email": "user37@example.com",
  "created_at": "2022-08-10T03:11:41.153Z",
  "updated_at": "2022-08-10T03:11:41.166Z",
  "locale": "en"
}

Delete a User

Request

curl "https://scfm.somleng.org/api/users/29" -d '' -X DELETE \
    -H "Authorization: Bearer MsfY5dh6w3w10ZRiiqODNP5TGLhYgaCl03GQJRzjwrI"

Endpoint

DELETE /api/users/:id

DELETE /api/users/29

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 jQbU43bLiR_cToNFEh8dDkw0bvaaUJfDv2pip20JgKA"

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": 20,
    "account_id": 448,
    "metadata": {
      "foo": "bar"
    },
    "email": "user27@example.com",
    "created_at": "2022-08-10T03:11:40.958Z",
    "updated_at": "2022-08-10T03:11:40.958Z",
    "locale": "en"
  }
]

Retrieve a User

Request

curl -g "https://scfm.somleng.org/api/users/27" -X GET \
    -H "Authorization: Bearer s5okOZxEVQTuBXudMgsJ1ERjcrBJVBBiU4lnsVQdh_E"

Endpoint

GET /api/users/:id

GET /api/users/27

Parameters

None known.

Response

Location: /api/users/27
200 OK
{
  "id": 27,
  "account_id": 455,
  "metadata": {
  },
  "email": "user34@example.com",
  "created_at": "2022-08-10T03:11:41.075Z",
  "updated_at": "2022-08-10T03:11:41.075Z",
  "locale": "en"
}

Update a User

Request

curl "https://scfm.somleng.org/api/users/28" -d '{
  "metadata": {
    "bar": "foo"
  },
  "metadata_merge_mode": "replace"
}' -X PATCH \
    -H "Authorization: Bearer Ta_5l0tNlfxeNk16DKK8cjOlAGq8DkyUjeLpSZje3xw"

Endpoint

PATCH /api/users/:id

PATCH /api/users/28

Parameters

{
  "metadata": {
    "bar": "foo"
  },
  "metadata_merge_mode": "replace"
}

None known.

Response

Location: /api/users/28
204 No Content