NAV
cURL

This is the API Documentation for Somleng Simple Call Flow Manager (Somleng SCFM).

Batch Operations

Create a Batch Operation Event

Request

Endpoint

POST /api/batch_operations/:batch_operation_id/batch_operation_events

POST https://scfm.somleng.org/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": "2025-01-08T09:23:26.309Z",
  "updated_at": "2025-01-08T09:23:26.309Z",
  "account_id": 410,
  "type": "BatchOperation::CalloutPopulation"
}

Create a batch operation with an invalid query

Request

Endpoint

POST /api/batch_operations

POST https://scfm.somleng.org/api/batch_operations

Parameters

{
  "metadata": {
    "foo": "bar"
  },
  "parameters": {
    "contact_filter_params": {
      "metadata": {
        "date_of_birth.data.gteq": "2022-01-01"
      }
    }
  },
  "type": "BatchOperation::CalloutPopulation",
  "callout_id": 187
}
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


422 Unprocessable Content
{
  "errors": {
    "contact_filter_params": [
      "is invalid"
    ]
  }
}

Create a batch operation with an invalid type

Request

Endpoint

POST /api/batch_operations

POST https://scfm.somleng.org/api/batch_operations

Parameters

{
  "metadata": {
    "foo": "bar"
  },
  "parameters": {},
  "type": "Contact"
}
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


422 Unprocessable Content
{
  "errors": {
    "callout": [
      "must exist"
    ]
  }
}

Delete a Batch Operation

Request

Endpoint

DELETE /api/batch_operations/:id

DELETE https://scfm.somleng.org/api/batch_operations/26

Parameters

None known.

Response

location: /api/batch_operations
204 No Content

Delete a callout population with callout participations

Request

Endpoint

DELETE /api/batch_operations/:id

DELETE https://scfm.somleng.org/api/batch_operations/27

Parameters

None known.

Response


422 Unprocessable Content
{
  "errors": {
    "base": [
      "Cannot delete record because dependent callout participations exist"
    ]
  }
}

List all Batch Operations

Request

Endpoint

GET /api/batch_operations

GET https://scfm.somleng.org/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": "2025-01-08T09:23:26.140Z",
    "updated_at": "2025-01-08T09:23:26.140Z",
    "account_id": 399,
    "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

Endpoint

POST /api/batch_operations

POST https://scfm.somleng.org/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": "2025-01-08T09:23:26.187Z",
  "updated_at": "2025-01-08T09:23:26.187Z",
  "account_id": 401,
  "type": "BatchOperation::CalloutPopulation"
}

Queue a finished batch operation

Request

Endpoint

POST /api/batch_operations/:batch_operation_id/batch_operation_events

POST https://scfm.somleng.org/api/batch_operations/29/batch_operation_events

Parameters

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

Response


422 Unprocessable Content
{
  "errors": {
    "event": [
      "is not included in the list"
    ]
  }
}

Retrieve a Batch Operation

Request

Endpoint

GET /api/batch_operations/:id

GET https://scfm.somleng.org/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": "2025-01-08T09:23:26.229Z",
  "updated_at": "2025-01-08T09:23:26.229Z",
  "account_id": 404,
  "type": "BatchOperation::CalloutPopulation"
}

Update a Batch Operation

Request

Endpoint

PATCH /api/batch_operations/:id

PATCH https://scfm.somleng.org/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

List all Callout Participations for a callout

Request

Endpoint

GET /api/callouts/:callout_id/callout_participations

GET https://scfm.somleng.org/api/callouts/195/callout_participations

Parameters

None known.

Response

per-page: 25
total: 1
200 OK
[
  {
    "id": 159,
    "callout_id": 195,
    "contact_id": 214,
    "callout_population_id": null,
    "msisdn": "+252662346000",
    "call_flow_logic": "CallFlowLogic::HelloWorld",
    "metadata": {},
    "created_at": "2025-01-08T09:23:26.360Z",
    "updated_at": "2025-01-08T09:23:26.360Z",
    "answered": false,
    "phone_calls_count": 0
  }
]

Callouts

Create a Callout

Request

Endpoint

POST /api/callouts

POST https://scfm.somleng.org/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/200
201 Created
{
  "id": 200,
  "status": "initialized",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
    "foo": "bar"
  },
  "created_at": "2025-01-08T09:23:26.410Z",
  "updated_at": "2025-01-08T09:23:26.410Z",
  "account_id": 415,
  "audio_url": "https://www.example.com/sample.mp3",
  "settings": {
    "external_service_1": {
      "foo": "bar"
    }
  },
  "created_by_id": null
}

Create a Callout Event

Request

Endpoint

POST /api/callouts/:callout_id/callout_events

POST https://scfm.somleng.org/api/callouts/205/callout_events

Parameters

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

Response

location: /api/callouts/205
201 Created
{
  "account_id": 420,
  "id": 205,
  "status": "running",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {},
  "created_at": "2025-01-08T09:23:26.491Z",
  "updated_at": "2025-01-08T09:23:26.501Z",
  "audio_url": null,
  "settings": {},
  "created_by_id": null
}

Delete a Callout

Request

Endpoint

DELETE /api/callouts/:id

DELETE https://scfm.somleng.org/api/callouts/203

Parameters

None known.

Response

location: /api/callouts
204 No Content

Delete a Callout with callout participations

Request

Endpoint

DELETE /api/callouts/:id

DELETE https://scfm.somleng.org/api/callouts/204

Parameters

None known.

Response


422 Unprocessable Content
{
  "errors": {
    "base": [
      "Cannot delete record because dependent callout participations exist"
    ]
  }
}

List all Callout Batch Operations

Request

Endpoint

GET /api/callouts/:callout_id/batch_operations

GET https://scfm.somleng.org/api/callouts/207/batch_operations

Parameters

None known.

Response

per-page: 25
total: 1
200 OK
[
  {
    "id": 30,
    "callout_id": 207,
    "parameters": {},
    "metadata": {},
    "status": "preview",
    "created_at": "2025-01-08T09:23:26.525Z",
    "updated_at": "2025-01-08T09:23:26.525Z",
    "account_id": 422,
    "type": "BatchOperation::CalloutPopulation"
  }
]

List all Callouts

Request

Endpoint

GET /api/callouts

GET https://scfm.somleng.org/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": "2025-01-08T09:23:26.383Z",
    "updated_at": "2025-01-08T09:23:26.383Z",
    "account_id": 413,
    "audio_url": null,
    "settings": {},
    "created_by_id": null
  }
]

Retrieve a Callout

Request

Endpoint

GET /api/callouts/:id

GET https://scfm.somleng.org/api/callouts/201

Parameters

None known.

Response

location: /api/callouts/201
200 OK
{
  "id": 201,
  "status": "initialized",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {},
  "created_at": "2025-01-08T09:23:26.419Z",
  "updated_at": "2025-01-08T09:23:26.419Z",
  "account_id": 416,
  "audio_url": null,
  "settings": {},
  "created_by_id": null
}

Start a running Callout

Request

Endpoint

POST /api/callouts/:callout_id/callout_events

POST https://scfm.somleng.org/api/callouts/206/callout_events

Parameters

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

Response


422 Unprocessable Content
{
  "errors": {
    "event": [
      "is not included in the list"
    ]
  }
}

Update a Callout

Request

Endpoint

PATCH /api/callouts/:id

PATCH https://scfm.somleng.org/api/callouts/202

Parameters

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

None known.

Response

location: /api/callouts/202
204 No Content

Phone Calls

List all Phone Calls

Request

Endpoint

GET /api/phone_calls

GET https://scfm.somleng.org/api/phone_calls?q[metadata][foo]=bar

Parameters

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

None known.

Response

per-page: 25
total: 1
200 OK
[
  {
    "id": 146,
    "callout_participation_id": 162,
    "contact_id": 217,
    "status": "created",
    "msisdn": "+252662346003",
    "remote_call_id": "1f4926f4-2e25-4e90-96e0-2bbd8f6e7432",
    "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": "2025-01-08T09:23:26.548Z",
    "updated_at": "2025-01-08T09:23:26.548Z",
    "duration": 0,
    "lock_version": 0,
    "account_id": 423,
    "remote_status_fetch_queued_at": null,
    "callout_id": 208
  }
]

List phone calls for a callout

Request

Endpoint

GET /api/callouts/:callout_id/phone_calls

GET https://scfm.somleng.org/api/callouts/211/phone_calls

Parameters

None known.

Response

per-page: 25
total: 1
200 OK
[
  {
    "id": 149,
    "callout_participation_id": 165,
    "contact_id": 220,
    "status": "created",
    "msisdn": "+252662346006",
    "remote_call_id": "363d7daf-ea72-42b4-846f-9fa29aa50a37",
    "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": "2025-01-08T09:23:26.620Z",
    "updated_at": "2025-01-08T09:23:26.620Z",
    "duration": 0,
    "lock_version": 0,
    "account_id": 426,
    "remote_status_fetch_queued_at": null,
    "callout_id": 211
  }
]

Retrieve a Phone Call

Request

Endpoint

GET /api/phone_calls/:id

GET https://scfm.somleng.org/api/phone_calls/151

Parameters

None known.

Response

location: /api/phone_calls/151
200 OK
{
  "id": 151,
  "callout_participation_id": 167,
  "contact_id": 222,
  "status": "created",
  "msisdn": "+252662346008",
  "remote_call_id": "de22f747-16bd-4d8d-a6cf-d22fe478c96f",
  "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": "2025-01-08T09:23:26.674Z",
  "updated_at": "2025-01-08T09:23:26.674Z",
  "duration": 0,
  "lock_version": 0,
  "account_id": 427,
  "remote_status_fetch_queued_at": null,
  "callout_id": 213
}

Recordings

List Recordings

Request

Endpoint

GET /api/recordings

GET https://scfm.somleng.org/api/recordings?q[created_at_or_after]=2025-01-08T09%3A23%3A26Z

Parameters

q: {"created_at_or_after"=>"2025-01-08T09:23:26Z"}

None known.

Response

per-page: 25
total: 1
200 OK
[
  {
    "id": 1,
    "phone_call_id": 152,
    "account_id": 428,
    "contact_id": 223,
    "external_recording_id": "3cfec33b-9def-4cb3-b66a-8a73bfbfc5cb",
    "external_recording_url": "https://api.somleng.org/2010-04-01/Accounts/b8c0f6cb-168f-4ad4-88f0-535a0baa00bc/Calls/e838fa82-6ff1-4ca4-bbd4-31c7163c2756/Recordings/3cfec33b-9def-4cb3-b66a-8a73bfbfc5cb",
    "duration": 15,
    "created_at": "2025-01-08T09:23:26.729Z",
    "updated_at": "2025-01-08T09:23:26.735Z"
  }
]

Retrieve a Recording

Request

Endpoint

GET /api/recordings/:id

GET https://scfm.somleng.org/api/recordings/4

Parameters

None known.

Response

location: /api/recordings/4
200 OK
{
  "id": 4,
  "phone_call_id": 155,
  "account_id": 435,
  "contact_id": 226,
  "external_recording_id": "cd3505bb-bbb2-4fde-aaba-261febc14e25",
  "external_recording_url": "https://api.somleng.org/2010-04-01/Accounts/62739954-2447-4209-a114-f1003bd5c871/Calls/0e41ef24-2b38-47f1-8b63-31ee8c5c3202/Recordings/cd3505bb-bbb2-4fde-aaba-261febc14e25",
  "duration": 15,
  "created_at": "2025-01-08T09:23:26.851Z",
  "updated_at": "2025-01-08T09:23:26.856Z"
}

Retrieve a recording as mp3

Request

Endpoint

GET /api/recordings/:id.mp3

GET https://scfm.somleng.org/api/recordings/5.mp3

Parameters

None known.

Response

location: https://scfm.somleng.org/rails/active_storage/disk/eyJfcmFpbHMiOnsiZGF0YSI6eyJrZXkiOiJseGxjcWxtbGEwbXlsNmZuNndhbDY5Y21tcjk3IiwiZGlzcG9zaXRpb24iOiJhdHRhY2htZW50OyBmaWxlbmFtZT1cInRlc3QubXAzXCI7IGZpbGVuYW1lKj1VVEYtOCcndGVzdC5tcDMiLCJjb250ZW50X3R5cGUiOiJhdWRpby9tcGVnIiwic2VydmljZV9uYW1lIjoidGVzdCJ9LCJleHAiOiIyMDI1LTAxLTA4VDA5OjI4OjI2LjkxNFoiLCJwdXIiOiJibG9iX2tleSJ9fQ==--2d1dee41ae153bf044cf11f56aa03a0ed384c242/test.mp3
302 Found