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

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": "r2ddkhzhHtHbSnjlw1YPzBGPVynGFnT25PANjDh3j7E",
  "created_at": "2022-08-24T08:29:48.090Z",
  "updated_at": "2022-08-24T08:29:48.092Z",
  "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 DVxI1huQlKFEHlxB_X8AQO25QqphqDt3FW3dKuw_fP0"

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 9cNtDQ6OZe5o-CObTwvNFTjZSLLcBrocG6Qg5syxcmU"

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": "DlOGpocFkXb11_7LodC5LYRq3zj6mTYIuEyZQmnGito",
    "created_at": "2022-08-24T08:29:47.988Z",
    "updated_at": "2022-08-24T08:29:47.990Z",
    "metadata": {
      "foo": "bar"
    },
    "permissions": [

    ]
  }
]

Retrieve an Access Token

Request

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

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": "IxC_tjFBKZFj53IDWfUn8eqcqECzJcLW9wgqE4YdDYc",
  "created_at": "2022-08-24T08:29:48.133Z",
  "updated_at": "2022-08-24T08:29:48.135Z",
  "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 aP-t-QzZjbHKdTS6RhmV6bbQFQqAKBB9CaVLlfIAZ2A"

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 FZNXztJPVHMAhBxNs0sbUQb749D2wG-ZAtkzq68fmQY"

Endpoint

GET /api/account

GET /api/account

Parameters

None known.

Response

Location: /api/accounts/389
200 OK
{
  "id": 389,
  "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-24T08:29:48.225Z",
  "updated_at": "2022-08-24T08:29:48.225Z",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "platform_provider_name": null,
  "somleng_api_host": null,
  "somleng_api_base_url": null,
  "phone_calls_count": 0,
  "contacts_count": 0
}

Update Account Details

Request

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

Endpoint

PATCH /api/account

PATCH /api/account

Parameters

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

None known.

Response

Location: /api/accounts/390
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 H_9c9YlBBrP-h_KLOumviCdr2kPZx_xJflW70nfKEhs"

Endpoint

POST /api/accounts

POST /api/accounts

Parameters

None known.

Response

Location: /api/accounts/395
201 Created
{
  "id": 395,
  "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-24T08:29:48.324Z",
  "updated_at": "2022-08-24T08:29:48.324Z",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "platform_provider_name": null,
  "somleng_api_host": null,
  "somleng_api_base_url": null,
  "phone_calls_count": 0,
  "contacts_count": 0
}

Delete an Account

Request

curl "https://scfm.somleng.org/api/accounts/400" -d '' -X DELETE \
    -H "Authorization: Bearer 170xckNByRifsqWJpWKArCmVMnZjiRgREkWTnN05CiU"

Endpoint

DELETE /api/accounts/:id

DELETE /api/accounts/400

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

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": 391,
    "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-24T08:29:48.267Z",
    "updated_at": "2022-08-24T08:29:48.267Z",
    "call_flow_logic": "CallFlowLogic::HelloWorld",
    "platform_provider_name": null,
    "somleng_api_host": null,
    "somleng_api_base_url": null,
    "phone_calls_count": 0,
    "contacts_count": 0
  }
]

Retrieve an Account

Request

curl -g "https://scfm.somleng.org/api/accounts/396" -X GET \
    -H "Authorization: Bearer ET44DBd6EOwpTeZDiWrUGVvMDfbmYeTv29F6OvgqPoY"

Endpoint

GET /api/accounts/:id

GET /api/accounts/396

Parameters

None known.

Response

Location: /api/accounts/396
200 OK
{
  "id": 396,
  "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-24T08:29:48.331Z",
  "updated_at": "2022-08-24T08:29:48.331Z",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "platform_provider_name": null,
  "somleng_api_host": null,
  "somleng_api_base_url": null,
  "phone_calls_count": 0,
  "contacts_count": 0
}

Update an Account

Request

curl "https://scfm.somleng.org/api/accounts/398" -d '{
  "metadata": {
    "foo": "bar"
  },
  "metadata_merge_mode": "replace",
  "twilio_account_sid": "AC8",
  "somleng_account_sid": "df554026-c6ed-4f7f-a92f-a5bcf776eb49",
  "twilio_auth_token": "054cdee6-6cb1-47f6-b340-4057a6e8c2bd",
  "somleng_auth_token": "be42cebf-980e-4178-8c05-f8d411bdebfc",
  "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 MJ1dZCP9O30xacA5OlNP_Jvco_g7-TK5M3VFSC2ajhs"

Endpoint

PATCH /api/accounts/:id

PATCH /api/accounts/398

Parameters

{
  "metadata": {
    "foo": "bar"
  },
  "metadata_merge_mode": "replace",
  "twilio_account_sid": "AC8",
  "somleng_account_sid": "df554026-c6ed-4f7f-a92f-a5bcf776eb49",
  "twilio_auth_token": "054cdee6-6cb1-47f6-b340-4057a6e8c2bd",
  "somleng_auth_token": "be42cebf-980e-4178-8c05-f8d411bdebfc",
  "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/398
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 FvJT-wTsJJgEPUMr7Ss7dscsO7jf9WaraaTDo3U1lHA"

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": 187,
  "parameters": {
  },
  "metadata": {
  },
  "status": "queued",
  "created_at": "2022-08-24T08:29:48.710Z",
  "updated_at": "2022-08-24T08:29:48.710Z",
  "account_id": 415,
  "type": "BatchOperation::CalloutPopulation"
}

Delete a Batch Operation

Request

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

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]=177" -X GET \
    -H "Authorization: Bearer YVej2k80PVRFHGTA0M6CuPvjg8-M7qgi1nvikqfhe1k"

Endpoint

GET /api/batch_operations

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

Parameters

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

None known.

Response

Per-Page: 25
Total: 1
200 OK
[
  {
    "id": 28,
    "callout_id": 177,
    "parameters": {
    },
    "metadata": {
    },
    "status": "preview",
    "created_at": "2022-08-24T08:29:48.447Z",
    "updated_at": "2022-08-24T08:29:48.447Z",
    "account_id": 404,
    "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": 180,
  "metadata": {
    "foo": "bar"
  },
  "parameters": {
    "contact_filter_params": {
      "metadata": {
        "gender": "f",
        "date_of_birth.date.gteq": "2022-01-01",
        "date_of_birth.date.lt": "2022-02-01",
        "deregistered_at.exists": false
      }
    }
  },
  "type": "BatchOperation::CalloutPopulation"
}' -X POST \
    -H "Authorization: Bearer FSZONEejgn2Y_WVY0e7_Ad5cXXnFtUJWOHWLStHSEns"

Endpoint

POST /api/batch_operations

POST /api/batch_operations

Parameters

{
  "callout_id": 180,
  "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/31
201 Created
{
  "id": 31,
  "callout_id": 180,
  "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": "2022-08-24T08:29:48.512Z",
  "updated_at": "2022-08-24T08:29:48.512Z",
  "account_id": 406,
  "type": "BatchOperation::CalloutPopulation"
}

Retrieve a Batch Operation

Request

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

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": 182,
  "parameters": {
  },
  "metadata": {
  },
  "status": "preview",
  "created_at": "2022-08-24T08:29:48.579Z",
  "updated_at": "2022-08-24T08:29:48.579Z",
  "account_id": 409,
  "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 9onwknTTiUzfYmppIgVBgHmPSzdppHyvwJS4cdD8568"

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/197/callout_participations" -d '{
  "contact_id": 190,
  "msisdn": "252662345965",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
    "foo": "bar"
  }
}' -X POST \
    -H "Authorization: Bearer 9FZrwws7B6CGmOhDJuN9QzGStOwmp9AuVinRDxFA4xQ"

Endpoint

POST /api/callouts/:callout_id/callout_participations

POST /api/callouts/197/callout_participations

Parameters

{
  "contact_id": 190,
  "msisdn": "252662345965",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
    "foo": "bar"
  }
}

None known.

Response

Location: /api/callout_participations/151
201 Created
{
  "id": 151,
  "callout_id": 197,
  "contact_id": 190,
  "callout_population_id": null,
  "msisdn": "+252662345965",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
    "foo": "bar"
  },
  "created_at": "2022-08-24T08:29:49.082Z",
  "updated_at": "2022-08-24T08:29:49.082Z",
  "answered": false,
  "phone_calls_count": 0
}

Create a Callout Participation with invalid data

Request

curl "https://scfm.somleng.org/api/callouts/198/callout_participations" -d '' -X POST \
    -H "Authorization: Bearer w756iS2GgFP73-Kl8f8lBMdGvkhxLeGT8I8n2ucTlZA"

Endpoint

POST /api/callouts/:callout_id/callout_participations

POST /api/callouts/198/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/154" -d '' -X DELETE \
    -H "Authorization: Bearer k7YzTRGRbgw50cCOLe2_Rj64mAC5qyRLbHvOTrByjRM"

Endpoint

DELETE /api/callout_participations/:id

DELETE /api/callout_participations/154

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/155" -d '' -X DELETE \
    -H "Authorization: Bearer A1DPh9TJqsLnZZemAe5ZHGtnCd05s-W-2lStRliaMYs"

Endpoint

DELETE /api/callout_participations/:id

DELETE /api/callout_participations/155

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

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": 144,
    "callout_id": 190,
    "contact_id": 183,
    "callout_population_id": null,
    "msisdn": "+252662345957",
    "call_flow_logic": "CallFlowLogic::HelloWorld",
    "metadata": {
      "foo": "bar"
    },
    "created_at": "2022-08-24T08:29:48.855Z",
    "updated_at": "2022-08-24T08:29:48.855Z",
    "answered": false,
    "phone_calls_count": 0
  }
]

Retrieve a Callout Participation

Request

curl -g "https://scfm.somleng.org/api/callout_participations/152" -X GET \
    -H "Authorization: Bearer yRyb5IS0l9QRWLQyYIh4mdO5Z9x-ITevxpONXOliutY"

Endpoint

GET /api/callout_participations/:id

GET /api/callout_participations/152

Parameters

None known.

Response

Location: /api/callout_participations/152
200 OK
{
  "id": 152,
  "callout_id": 199,
  "contact_id": 191,
  "callout_population_id": null,
  "msisdn": "+252662345966",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
  },
  "created_at": "2022-08-24T08:29:49.160Z",
  "updated_at": "2022-08-24T08:29:49.160Z",
  "answered": false,
  "phone_calls_count": 0
}

Update a Callout Participation

Request

curl "https://scfm.somleng.org/api/callout_participations/153" -d '{
  "contact_id": 193,
  "msisdn": "252662345969",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
    "bar": "foo"
  },
  "metadata_merge_mode": "replace"
}' -X PATCH \
    -H "Authorization: Bearer 33g32Tc6--YfyanueqYFOEg5GBv0yIicDWRXoU6V00Y"

Endpoint

PATCH /api/callout_participations/:id

PATCH /api/callout_participations/153

Parameters

{
  "contact_id": 193,
  "msisdn": "252662345969",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
    "bar": "foo"
  },
  "metadata_merge_mode": "replace"
}

None known.

Response

Location: /api/callout_participations/153
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 0YdRzoeoTz_ir3IcZx3ZbO3O_ly0AlhNaI2PxN1YaH8"

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/208
201 Created
{
  "id": 208,
  "status": "initialized",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
    "foo": "bar"
  },
  "created_at": "2022-08-24T08:29:49.435Z",
  "updated_at": "2022-08-24T08:29:49.435Z",
  "account_id": 432,
  "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/213/callout_events" -d '{
  "event": "start"
}' -X POST \
    -H "Authorization: Bearer CSV8N3XMIWzpHvHFRVw_XJQzHw0wclkCBForYrXB0nc"

Endpoint

POST /api/callouts/:callout_id/callout_events

POST /api/callouts/213/callout_events

Parameters

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

Response

Location: /api/callouts/213
201 Created
{
  "account_id": 437,
  "id": 213,
  "status": "running",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
  },
  "created_at": "2022-08-24T08:29:49.558Z",
  "updated_at": "2022-08-24T08:29:49.578Z",
  "audio_url": null,
  "settings": {
  },
  "created_by_id": null
}

Delete a Callout

Request

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

Endpoint

DELETE /api/callouts/:id

DELETE /api/callouts/211

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 MDG0JO8P_IWXprS7gKoz1ixscxddnLjeemhZ--77qm4"

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": 203,
    "status": "initialized",
    "call_flow_logic": "CallFlowLogic::HelloWorld",
    "metadata": {
      "foo": "bar"
    },
    "created_at": "2022-08-24T08:29:49.355Z",
    "updated_at": "2022-08-24T08:29:49.355Z",
    "account_id": 429,
    "audio_url": null,
    "settings": {
    },
    "created_by_id": null
  }
]

Retrieve a Callout

Request

curl -g "https://scfm.somleng.org/api/callouts/209" -X GET \
    -H "Authorization: Bearer h8xQvlTqHzR9qKnc4G__vXz9Zyjy-z33sevmQWnYNDc"

Endpoint

GET /api/callouts/:id

GET /api/callouts/209

Parameters

None known.

Response

Location: /api/callouts/209
200 OK
{
  "id": 209,
  "status": "initialized",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "metadata": {
  },
  "created_at": "2022-08-24T08:29:49.447Z",
  "updated_at": "2022-08-24T08:29:49.447Z",
  "account_id": 433,
  "audio_url": null,
  "settings": {
  },
  "created_by_id": null
}

Update a Callout

Request

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

Endpoint

PATCH /api/callouts/:id

PATCH /api/callouts/210

Parameters

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

None known.

Response

Location: /api/callouts/210
204 No Content

Contacts

Create a Contact

Request

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

Endpoint

POST /api/contacts

POST /api/contacts

Parameters

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

Response

Location: /api/contacts/203
201 Created
{
  "id": 203,
  "msisdn": "+252662345979",
  "metadata": {
    "gender": "f",
    "name": "Kate"
  },
  "created_at": "2022-08-24T08:29:49.733Z",
  "updated_at": "2022-08-24T08:29:49.733Z",
  "account_id": 443
}

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": "252662345983",
  "metadata": {
    "gender": "f",
    "name": "Kate"
  }
}' -X POST \
    -H "Authorization: Bearer W1mSYcPD-74s555YoyCGWYEgai_9g5xDDbIBg2_rJxs"

Endpoint

POST /api/contact_data

POST /api/contact_data

Parameters

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

None known.

Response

Location: /api/contacts/207
201 Created
{
  "id": 207,
  "msisdn": "+252662345983",
  "metadata": {
    "gender": "f",
    "name": "Kate"
  },
  "created_at": "2022-08-24T08:29:49.861Z",
  "updated_at": "2022-08-24T08:29:49.861Z",
  "account_id": 448
}

Delete a Contact

Request

curl "https://scfm.somleng.org/api/contacts/209" -d '' -X DELETE \
    -H "Authorization: Bearer j3ql3ALfuOMnhtC4xVd8TH-9-twmfx7WRM_cNzTGXd4"

Endpoint

DELETE /api/contacts/:id

DELETE /api/contacts/209

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 DmM8R9lwdR5tD1IxtN-Q7wZFYZLOayeHj1OUFRUDXyk"

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": 198,
    "msisdn": "+252662345974",
    "metadata": {
      "foo": "bar"
    },
    "created_at": "2022-08-24T08:29:49.640Z",
    "updated_at": "2022-08-24T08:29:49.640Z",
    "account_id": 440
  }
]

Retrieve a Contact

Request

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

Endpoint

GET /api/contacts/:id

GET /api/contacts/204

Parameters

None known.

Response

Location: /api/contacts/204
200 OK
{
  "id": 204,
  "msisdn": "+252662345980",
  "metadata": {
  },
  "created_at": "2022-08-24T08:29:49.769Z",
  "updated_at": "2022-08-24T08:29:49.769Z",
  "account_id": 445
}

Update a Contact

Request

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

Endpoint

PATCH /api/contacts/:id

PATCH /api/contacts/205

Parameters

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

None known.

Response

Location: /api/contacts/205
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 MAELeLCeYOf2z3LOfX3Ebppb3hFzzMsyf98rDG7gnvc"

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": 131,
    "callout_participation_id": 160,
    "contact_id": 212,
    "status": "created",
    "msisdn": "+252662345988",
    "remote_call_id": "54f6ad25-bf48-4472-822d-0ddc7238c519",
    "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-24T08:29:49.982Z",
    "updated_at": "2022-08-24T08:29:49.982Z",
    "duration": 0,
    "lock_version": 0,
    "account_id": 452,
    "remote_status_fetch_queued_at": null,
    "callout_id": 218
  }
]

Retrieve a Phone Call

Request

curl -g "https://scfm.somleng.org/api/phone_calls/140" -X GET \
    -H "Authorization: Bearer y2XYKkSFdpWfQiQAjfpaD6dahKXxjjyMJ3Y_f-ZrXTI"

Endpoint

GET /api/phone_calls/:id

GET /api/phone_calls/140

Parameters

None known.

Response

Location: /api/phone_calls/140
200 OK
{
  "id": 140,
  "callout_participation_id": 169,
  "contact_id": 221,
  "status": "created",
  "msisdn": "+252662345997",
  "remote_call_id": "aaec2db5-2e83-4a9c-b123-8864dbfeedbb",
  "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-24T08:29:50.211Z",
  "updated_at": "2022-08-24T08:29:50.211Z",
  "duration": 0,
  "lock_version": 0,
  "account_id": 458,
  "remote_status_fetch_queued_at": null,
  "callout_id": 227
}

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 5FZV1OamSOjiFpz5fiwQfeBnQaMRdhbuMSD91WUdTVY"

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": 63,
    "phone_call_id": 141,
    "details": {
      "To": "345",
      "From": "252662345999",
      "CallSid": "bf7252fa-619c-4c5b-be2b-a8d82e45542c",
      "Direction": "inbound",
      "AccountSid": "da72777f-fb18-4515-b7d9-ace80b7a1176",
      "ApiVersion": "2010-04-01",
      "CallStatus": "completed"
    },
    "metadata": {
      "foo": "bar"
    },
    "remote_call_id": "bf7252fa-619c-4c5b-be2b-a8d82e45542c",
    "remote_direction": "inbound",
    "call_flow_logic": "CallFlowLogic::HelloWorld",
    "created_at": "2022-08-24T08:29:50.252Z",
    "updated_at": "2022-08-24T08:29:50.252Z",
    "call_duration": 0
  }
]

Retrieve a Remote Phone Call Event

Request

curl -g "https://scfm.somleng.org/api/remote_phone_call_events/74" -X GET \
    -H "Authorization: Bearer yqp-mSNxb4xnYeUVjAYEPMkAtq59AGcPDKxOFpHW1QQ"

Endpoint

GET /api/remote_phone_call_events/:id

GET /api/remote_phone_call_events/74

Parameters

None known.

Response

Location: /api/remote_phone_call_events/74
200 OK
{
  "id": 74,
  "phone_call_id": 152,
  "details": {
    "To": "345",
    "From": "252662346021",
    "CallSid": "e78392a9-a6cc-48ea-b85a-fc4c7b7e1e51",
    "Direction": "inbound",
    "AccountSid": "59590be3-6ab0-4f8e-a65c-874ed4f54c38",
    "ApiVersion": "2010-04-01",
    "CallStatus": "completed"
  },
  "metadata": {
  },
  "remote_call_id": "e78392a9-a6cc-48ea-b85a-fc4c7b7e1e51",
  "remote_direction": "inbound",
  "call_flow_logic": "CallFlowLogic::HelloWorld",
  "created_at": "2022-08-24T08:29:50.561Z",
  "updated_at": "2022-08-24T08:29:50.561Z",
  "call_duration": 0
}

Update a Remote Phone Call Event

Request

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

Endpoint

PATCH /api/remote_phone_call_events/:id

PATCH /api/remote_phone_call_events/75

Parameters

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

None known.

Response

Location: /api/remote_phone_call_events/75
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-23&sort=-id%2Ccreated_at" -X GET \
    -H "Authorization: Bearer 5GfgVH5cL0ul81BPP_3lV-DOUox6goYhtGRAbks5_Jc"

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-23&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-23"}
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": 263,
    "msisdn": "+252662346050",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.834Z",
    "updated_at": "2022-08-24T08:29:50.834Z",
    "account_id": 472
  },
  {
    "id": 262,
    "msisdn": "+252662346049",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.831Z",
    "updated_at": "2022-08-24T08:29:50.831Z",
    "account_id": 472
  },
  {
    "id": 261,
    "msisdn": "+252662346048",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.828Z",
    "updated_at": "2022-08-24T08:29:50.828Z",
    "account_id": 472
  },
  {
    "id": 260,
    "msisdn": "+252662346047",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.825Z",
    "updated_at": "2022-08-24T08:29:50.825Z",
    "account_id": 472
  },
  {
    "id": 259,
    "msisdn": "+252662346046",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.822Z",
    "updated_at": "2022-08-24T08:29:50.822Z",
    "account_id": 472
  },
  {
    "id": 258,
    "msisdn": "+252662346045",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.819Z",
    "updated_at": "2022-08-24T08:29:50.819Z",
    "account_id": 472
  },
  {
    "id": 257,
    "msisdn": "+252662346044",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.815Z",
    "updated_at": "2022-08-24T08:29:50.815Z",
    "account_id": 472
  },
  {
    "id": 256,
    "msisdn": "+252662346043",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.812Z",
    "updated_at": "2022-08-24T08:29:50.812Z",
    "account_id": 472
  },
  {
    "id": 255,
    "msisdn": "+252662346042",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.809Z",
    "updated_at": "2022-08-24T08:29:50.809Z",
    "account_id": 472
  },
  {
    "id": 254,
    "msisdn": "+252662346041",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.806Z",
    "updated_at": "2022-08-24T08:29:50.806Z",
    "account_id": 472
  },
  {
    "id": 253,
    "msisdn": "+252662346040",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.803Z",
    "updated_at": "2022-08-24T08:29:50.803Z",
    "account_id": 472
  },
  {
    "id": 252,
    "msisdn": "+252662346039",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.799Z",
    "updated_at": "2022-08-24T08:29:50.799Z",
    "account_id": 472
  },
  {
    "id": 251,
    "msisdn": "+252662346038",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.796Z",
    "updated_at": "2022-08-24T08:29:50.796Z",
    "account_id": 472
  },
  {
    "id": 250,
    "msisdn": "+252662346037",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.793Z",
    "updated_at": "2022-08-24T08:29:50.793Z",
    "account_id": 472
  },
  {
    "id": 249,
    "msisdn": "+252662346036",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.790Z",
    "updated_at": "2022-08-24T08:29:50.790Z",
    "account_id": 472
  },
  {
    "id": 248,
    "msisdn": "+252662346035",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.787Z",
    "updated_at": "2022-08-24T08:29:50.787Z",
    "account_id": 472
  },
  {
    "id": 247,
    "msisdn": "+252662346034",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.784Z",
    "updated_at": "2022-08-24T08:29:50.784Z",
    "account_id": 472
  },
  {
    "id": 246,
    "msisdn": "+252662346033",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.781Z",
    "updated_at": "2022-08-24T08:29:50.781Z",
    "account_id": 472
  },
  {
    "id": 245,
    "msisdn": "+252662346032",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.777Z",
    "updated_at": "2022-08-24T08:29:50.777Z",
    "account_id": 472
  },
  {
    "id": 244,
    "msisdn": "+252662346031",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.774Z",
    "updated_at": "2022-08-24T08:29:50.774Z",
    "account_id": 472
  },
  {
    "id": 243,
    "msisdn": "+252662346030",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.771Z",
    "updated_at": "2022-08-24T08:29:50.771Z",
    "account_id": 472
  },
  {
    "id": 242,
    "msisdn": "+252662346029",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.768Z",
    "updated_at": "2022-08-24T08:29:50.768Z",
    "account_id": 472
  },
  {
    "id": 241,
    "msisdn": "+252662346028",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.765Z",
    "updated_at": "2022-08-24T08:29:50.765Z",
    "account_id": 472
  },
  {
    "id": 240,
    "msisdn": "+252662346027",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.760Z",
    "updated_at": "2022-08-24T08:29:50.760Z",
    "account_id": 472
  },
  {
    "id": 239,
    "msisdn": "+252662346026",
    "metadata": {
      "gender": "f",
      "date_of_birth": "2022-01-15"
    },
    "created_at": "2022-08-24T08:29:50.757Z",
    "updated_at": "2022-08-24T08:29:50.757Z",
    "account_id": 472
  }
]

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

Endpoint

PATCH /api/contacts/:id

PATCH /api/contacts/265

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/265
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 z9NpyRxLcT1TPymUo9HxG_oSrOlAEPyEVkHGON_OlpU"

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": 478,
  "metadata": {
    "foo": "bar"
  },
  "email": "user32@example.com",
  "created_at": "2022-08-24T08:29:50.982Z",
  "updated_at": "2022-08-24T08:29:50.982Z",
  "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 E2PHO-gURT5fgxqQu0QoQSQFapdUUwXvborX8-beJeY"

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": 484,
  "id": 30,
  "metadata": {
  },
  "email": "user37@example.com",
  "created_at": "2022-08-24T08:29:51.112Z",
  "updated_at": "2022-08-24T08:29:51.127Z",
  "locale": "en"
}

Delete a User

Request

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

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 wThl-gAf-37GrwDh2Kdou2cVL8AhN8MKyMj_ovuqV7c"

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": 474,
    "metadata": {
      "foo": "bar"
    },
    "email": "user27@example.com",
    "created_at": "2022-08-24T08:29:50.897Z",
    "updated_at": "2022-08-24T08:29:50.897Z",
    "locale": "en"
  }
]

Retrieve a User

Request

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

Endpoint

GET /api/users/:id

GET /api/users/27

Parameters

None known.

Response

Location: /api/users/27
200 OK
{
  "id": 27,
  "account_id": 481,
  "metadata": {
  },
  "email": "user34@example.com",
  "created_at": "2022-08-24T08:29:51.025Z",
  "updated_at": "2022-08-24T08:29:51.025Z",
  "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 xQE1oIuaw-2YYgi431rqoU5p2Fc8burUecW6V1I1uLI"

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