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 K-zQtwpFG72540b1QpC39ciVlCAplY7Ck4F5-QvBMZw"

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": "lcj6K3zw6QsA-95u0kthjAomCuVOCF6Uff4kQSfkcY4",
  "created_at": "2022-06-03T02:12:24.931Z",
  "updated_at": "2022-06-03T02:12:24.933Z",
  "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 9jiZra2SEG514UydB5EdTMIIkLv5NRZPNzhY5XhMVTU"

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

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": "f2Mdt0lymCqAb2xzoNJ5Ue6h_erLTQav66AfxNQiAfY",
    "created_at": "2022-06-03T02:12:24.816Z",
    "updated_at": "2022-06-03T02:12:24.817Z",
    "metadata": {
      "foo": "bar"
    },
    "permissions": [

    ]
  }
]

Retrieve an Access Token

Request

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

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": "j4CFgpEaUlYDzndrQQxBBiImrPDtrqlyJTZ8pJjdntg",
  "created_at": "2022-06-03T02:12:24.975Z",
  "updated_at": "2022-06-03T02:12:24.977Z",
  "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 aju1UIHqdQb0ZYpqO0jQlfLCxc_WPLcskAIWLaSl_Vg"

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 7VpsFARq75Wj1WruRlUT6NhTf3NNCOg-aH6Su5q8jl8"

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-06-03T02:12:25.073Z",
  "updated_at": "2022-06-03T02:12:25.073Z",
  "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 uEH8MVHmNn6Xr7uZC0aRO4uXN3eXc2WVOHD6XjkGxwA"

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

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-06-03T02:12:25.180Z",
  "updated_at": "2022-06-03T02:12:25.180Z",
  "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 -TU7QItTdb4Bf_DLfvZmBo4AOA_dmU7iTXZzH14Ik9s"

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 iwbcpRwXzBO6kzEu3Oar-8iJv6OqXCo4O7eaH12zXms"

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-06-03T02:12:25.119Z",
    "updated_at": "2022-06-03T02:12:25.119Z",
    "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 nJ5rGD_krxND8CgbFxQeD-hrGqxV0Z-Hc3aVQ8654sw"

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-06-03T02:12:25.188Z",
  "updated_at": "2022-06-03T02:12:25.188Z",
  "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": "1364b180-c383-4638-bdd4-e2f232e9e0b6",
  "twilio_auth_token": "5e2c927e-3f66-41bf-95f8-bcc64fe7af18",
  "somleng_auth_token": "4b078b48-f0fb-4d17-93a0-b7bcd2b2bb17",
  "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 vIogONft9sU3yfQAx6NRctNPwlC2Tnz3thMBSRo60Ok"

Endpoint

PATCH /api/accounts/:id

PATCH /api/accounts/372

Parameters

{
  "metadata": {
    "foo": "bar"
  },
  "metadata_merge_mode": "replace",
  "twilio_account_sid": "AC8",
  "somleng_account_sid": "1364b180-c383-4638-bdd4-e2f232e9e0b6",
  "twilio_auth_token": "5e2c927e-3f66-41bf-95f8-bcc64fe7af18",
  "somleng_auth_token": "4b078b48-f0fb-4d17-93a0-b7bcd2b2bb17",
  "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 5fHib6tQMd2QkXv3YhhnJVqf-RzyzE8nfl7toH3PwfY"

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-06-03T02:12:25.779Z",
  "updated_at": "2022-06-03T02:12:25.779Z",
  "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 igcs8O6X1eP1P9hJhLh_x5x7W1r5AN0QHThJiz65jC4"

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

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-06-03T02:12:25.383Z",
    "updated_at": "2022-06-03T02:12:25.383Z",
    "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 5nSkVITrHWj0KAU9cbZiFQY7ypSn0UMyNUSLTGzU73M"

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-06-03T02:12:25.466Z",
  "updated_at": "2022-06-03T02:12:25.466Z",
  "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 7H5WYrzg_qSIJDjuP87mJsR5momk9whhd6sog9zpGzg"

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-06-03T02:12:25.574Z",
  "updated_at": "2022-06-03T02:12:25.574Z",
  "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 DkiEvLDdmkxxUYKfW-TOB18ZZZKNB3Bhr2w9pUmXr2w"

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 a7nlVXi4axQ2IkT8yOX-9ExjZBdUuSET-z8t8JL2B-g"

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-06-03T02:12:26.045Z",
  "updated_at": "2022-06-03T02:12:26.045Z",
  "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 s8IDjDHBhpxH_cTAwM38bPouXnbro2VwGJPIW85YYro"

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 pvRboPeEb5isFJyGrM-UWYSxKSpvOf3eQFl5IlJeUlA"

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 9g3rKTmTyt-EVRAEpRSIqPb6SG3rpfYSant1BPMCr6c"

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 L-L9ir_MHInMNiOGgIYk8pEobYYHxbjMf0N1XjgCZbM"

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-06-03T02:12:25.894Z",
    "updated_at": "2022-06-03T02:12:25.894Z",
    "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 ofI4-FBBpRPmH98nNe7vj3CoO9UcYR6XDyF4xK4JRUY"

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-06-03T02:12:26.090Z",
  "updated_at": "2022-06-03T02:12:26.090Z",
  "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 -K9Mi4h_eHCC_vAOzLpYFfsFb9_NbHDfpwmcTg8vOJA"

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

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-06-03T02:12:26.311Z",
  "updated_at": "2022-06-03T02:12:26.311Z",
  "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 23KjqDfyGvX5KMI05FWWPod_IkE_JsaXLhTvEup1cZM"

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-06-03T02:12:26.446Z",
  "updated_at": "2022-06-03T02:12:26.466Z",
  "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 j888gI6UKaJSO2_VPUqCaic8rlLFAHKu842dSE5p8A0"

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 -vz1DeNYkhwKGqp37AI0CW8xewY-Tnk3eQXbe2b2wlY"

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-06-03T02:12:26.224Z",
    "updated_at": "2022-06-03T02:12:26.224Z",
    "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 uT_RkSIafpdFMo6U55r4Y6Gk9PbE7h6FwddAN0FFVhc"

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-06-03T02:12:26.323Z",
  "updated_at": "2022-06-03T02:12:26.323Z",
  "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 PcnycKNyVwqeVjhdaPud3ACQxCmgfAvYTPjsCcuCB8s"

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 r_0R-vXQm28JJ1MIGEd9IsMh3kUQWxrYw6aefZtyJ9E"

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-06-03T02:12:26.618Z",
  "updated_at": "2022-06-03T02:12:26.618Z",
  "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 3INMXpribxSptpt0s5fCrl8Evyp-0iw-wU2TYL7UHQo"

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-06-03T02:12:26.738Z",
  "updated_at": "2022-06-03T02:12:26.738Z",
  "account_id": 422
}

Delete a Contact

Request

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

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

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-06-03T02:12:26.534Z",
    "updated_at": "2022-06-03T02:12:26.534Z",
    "account_id": 414
  }
]

Retrieve a Contact

Request

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

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-06-03T02:12:26.647Z",
  "updated_at": "2022-06-03T02:12:26.647Z",
  "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 xHFQm3_WCY6628vWU-rwWhaI4O1NZc2VSpREZ5JOaus"

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

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": "b17c4c7d-af19-4198-a7b5-0c1da8099012",
    "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-06-03T02:12:26.848Z",
    "updated_at": "2022-06-03T02:12:26.848Z",
    "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 pvycXI2YhuZRSnoFOdsf2Z3pT1pxP5IW-TpOK6PsdkI"

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": "6e0a4a1d-7290-41c6-9e66-7a1891528022",
  "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-06-03T02:12:27.080Z",
  "updated_at": "2022-06-03T02:12:27.080Z",
  "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 L4pl1AlRGE5aw4WevXdAs89yoMobdQaUZkqbFJIUR9U"

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": "fdeadb8d-0876-4af3-a07a-3d0aea1bb6ed",
      "Direction": "inbound",
      "AccountSid": "d6194796-650c-45bd-8a08-d8b5c7d03376",
      "ApiVersion": "2010-04-01",
      "CallStatus": "completed"
    },
    "metadata": {
      "foo": "bar"
    },
    "remote_call_id": "fdeadb8d-0876-4af3-a07a-3d0aea1bb6ed",
    "remote_direction": "inbound",
    "call_flow_logic": "CallFlowLogic::HelloWorld",
    "created_at": "2022-06-03T02:12:27.127Z",
    "updated_at": "2022-06-03T02:12:27.127Z",
    "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 vE-nDANC80At2AiN5jziquO3J8kmnb_EIJ2idfcliBk"

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": "c8e85ce0-ef55-4fb0-855e-f71b06bdb057",
    "Direction": "inbound",
    "AccountSid": "4583930c-0cf9-44c0-9dbe-773c9b43dcec",
    "ApiVersion": "2010-04-01",
    "CallStatus": "completed"
  },
  "metadata": {
  },
  "remote_call_id": "c8e85ce0-ef55-4fb0-855e-f71b06bdb057",
  "remote_direction": "inbound",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "created_at": "2022-06-03T02:12:27.447Z",
  "updated_at": "2022-06-03T02:12:27.447Z",
  "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 febOruL8q5K9M6nSw3XMRhA-z1uunPGyodZEyUCrD1U"

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-06-02&sort=-id%2Ccreated_at" -X GET \
    -H "Authorization: Bearer qT0oPlhESQUyJyvhCwT6et9CTtfZkS4BzU91P_5B4w8"

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-06-02&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-06-02"}
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-06-03T02:12:27.716Z",
    "updated_at": "2022-06-03T02:12:27.716Z",
    "account_id": 446
  },
  {
    "id": 242,
    "msisdn": "+252662346021",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.714Z",
    "updated_at": "2022-06-03T02:12:27.714Z",
    "account_id": 446
  },
  {
    "id": 241,
    "msisdn": "+252662346020",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.711Z",
    "updated_at": "2022-06-03T02:12:27.711Z",
    "account_id": 446
  },
  {
    "id": 240,
    "msisdn": "+252662346019",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.709Z",
    "updated_at": "2022-06-03T02:12:27.709Z",
    "account_id": 446
  },
  {
    "id": 239,
    "msisdn": "+252662346018",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.706Z",
    "updated_at": "2022-06-03T02:12:27.706Z",
    "account_id": 446
  },
  {
    "id": 238,
    "msisdn": "+252662346017",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.703Z",
    "updated_at": "2022-06-03T02:12:27.703Z",
    "account_id": 446
  },
  {
    "id": 237,
    "msisdn": "+252662346016",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.701Z",
    "updated_at": "2022-06-03T02:12:27.701Z",
    "account_id": 446
  },
  {
    "id": 236,
    "msisdn": "+252662346015",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.698Z",
    "updated_at": "2022-06-03T02:12:27.698Z",
    "account_id": 446
  },
  {
    "id": 235,
    "msisdn": "+252662346014",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.696Z",
    "updated_at": "2022-06-03T02:12:27.696Z",
    "account_id": 446
  },
  {
    "id": 234,
    "msisdn": "+252662346013",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.693Z",
    "updated_at": "2022-06-03T02:12:27.693Z",
    "account_id": 446
  },
  {
    "id": 233,
    "msisdn": "+252662346012",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.691Z",
    "updated_at": "2022-06-03T02:12:27.691Z",
    "account_id": 446
  },
  {
    "id": 232,
    "msisdn": "+252662346011",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.688Z",
    "updated_at": "2022-06-03T02:12:27.688Z",
    "account_id": 446
  },
  {
    "id": 231,
    "msisdn": "+252662346010",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.685Z",
    "updated_at": "2022-06-03T02:12:27.685Z",
    "account_id": 446
  },
  {
    "id": 230,
    "msisdn": "+252662346009",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.683Z",
    "updated_at": "2022-06-03T02:12:27.683Z",
    "account_id": 446
  },
  {
    "id": 229,
    "msisdn": "+252662346008",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.680Z",
    "updated_at": "2022-06-03T02:12:27.680Z",
    "account_id": 446
  },
  {
    "id": 228,
    "msisdn": "+252662346007",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.678Z",
    "updated_at": "2022-06-03T02:12:27.678Z",
    "account_id": 446
  },
  {
    "id": 227,
    "msisdn": "+252662346006",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.675Z",
    "updated_at": "2022-06-03T02:12:27.675Z",
    "account_id": 446
  },
  {
    "id": 226,
    "msisdn": "+252662346005",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.673Z",
    "updated_at": "2022-06-03T02:12:27.673Z",
    "account_id": 446
  },
  {
    "id": 225,
    "msisdn": "+252662346004",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.670Z",
    "updated_at": "2022-06-03T02:12:27.670Z",
    "account_id": 446
  },
  {
    "id": 224,
    "msisdn": "+252662346003",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.668Z",
    "updated_at": "2022-06-03T02:12:27.668Z",
    "account_id": 446
  },
  {
    "id": 223,
    "msisdn": "+252662346002",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.665Z",
    "updated_at": "2022-06-03T02:12:27.665Z",
    "account_id": 446
  },
  {
    "id": 222,
    "msisdn": "+252662346001",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.663Z",
    "updated_at": "2022-06-03T02:12:27.663Z",
    "account_id": 446
  },
  {
    "id": 221,
    "msisdn": "+252662346000",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.660Z",
    "updated_at": "2022-06-03T02:12:27.660Z",
    "account_id": 446
  },
  {
    "id": 220,
    "msisdn": "+252662345999",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.658Z",
    "updated_at": "2022-06-03T02:12:27.658Z",
    "account_id": 446
  },
  {
    "id": 219,
    "msisdn": "+252662345998",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-06-03T02:12:27.655Z",
    "updated_at": "2022-06-03T02:12:27.655Z",
    "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 axpo_Er9nPYJFxFlG50iyzGZBbD8GT3uzQdOunzfOK0"

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

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-06-03T02:12:27.873Z",
  "updated_at": "2022-06-03T02:12:27.873Z",
  "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 81kw4YQWDNbVJNe_VXHoqNvnrms-GrTcY-3wjL78fhw"

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-06-03T02:12:28.072Z",
  "updated_at": "2022-06-03T02:12:28.097Z",
  "locale": "en"
}

Delete a User

Request

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

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 HHJM-LeInReD2PBVqqJlBPOx20QOTq97F5uZSLW1xEc"

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-06-03T02:12:27.781Z",
    "updated_at": "2022-06-03T02:12:27.781Z",
    "locale": "en"
  }
]

Retrieve a User

Request

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

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-06-03T02:12:27.928Z",
  "updated_at": "2022-06-03T02:12:27.928Z",
  "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 rsCrrYVFXeuqUcZ3GwJ4SU_ZZM-A4IJpVEKJGuONz6I"

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