REST API‎ > ‎Media Management‎ > ‎

Record

This method causes the specified networkid to be called and played a "record greeting" prompt. The status of the recording can subsequently be determined by calling the "media status" method and supplying the appropriate Media ID.

Method: POST
URI: /api/rest/media/{mediaid}

Path parameter: 
  • mediaid  The media ID to associate with the recorded audio.
Form parameters:
  • networkid  The networkid to call.
  • appkey  The application key associated with both the networkid and the application.
  • action  The action to perform - ("record").
  • greetingid Optional.  The media ID of a pre-recorded greeting, to be played when the phone is answered.  If this parameter is not supplied, the default greeting will be used.
Returns:
  • ACCEPTED(202) - The "record" request has been accepted.
  • BAD_REQUEST(400) - Missing parameter(s).
  • NOT_FOUND(404) - The application key is invalid or the application is not associated with the networkid.
  • BAD_GATEWAY(502) - Unable to initiate phone call at this time.
Response format: JSON

Example using curl

curl -d "appkey=1f1bbca5-b71f-4938-97b6-59fed80623bc&action=record&networkid=eta" "https://api.telesocial.com/api/rest/media/6e6a151be31b467f87225b18b0f36f00"

Response body:

{"MediaResponse":"message":"","status":201,"downloadUrl":"","fileSize":0,"mediaId":"6e6a151be31b467f87225b18b0f36f00","uri":"\/api\/rest\/media\/6e6a151be31b467f87225b18b0f36f00"}}


PHP Example Code

 public function createMedia($networkID, $greetingID = '380b6ae9a61235948a2988667b35f0ae71d')
    {
        $query = new telesocialQuery('media');
        $query->addApiKey();

        if ($query->make() && $query->response['status'] == 201)
        {
            //Getting media ID
            $mediaID = $query->response['mediaId'];

            //Recording
            $query = new telesocialQuery('media', $mediaID);
            $query->addApiKey();
            $query->add('networkid', $networkID);
            $query->add('action', 'record');
            if ($greetingID)
            {
                $query->add('greetingid', $greetingID);
            }

            if ($query->make() && $query->response['status'] == 202)
            {
                return $mediaID;
            }
        }

        return false;
    }