Creating a shared link via API and Curl

New post



  • Nayak

    I did try the same in Postman with the body as below and confirm that the shared link was created with the expiry date set.

    {"shared_link": {"access": "open", "unshared_at": "2020-12-12T10:53:43-08:00"}}


    Not sure if you are trying this in a free account as shared link expiry is only available to paid accounts.

    :The timestamp at which this shared link will expire. This field can only be set by users with paid accounts."



    Comment actions Permalink
  • womble

    Thank you for you reply. I do have a paid account. Your response gave me the confidence to keep trying.


    It turns out I was not forming the parameters right in Guzzle and Curl. In case anybody else needs this, to get it to work in PHP, with Guzzle:


    $unshare_date = "2020-12-12T10:53:43-08:00";
    $api_url = '' . $fileId;    
    $query = ['fields' => 'shared_link'];
    $json = ['shared_link' => ['access' => 'open', 'unshared_at' => $unshare_date]];
    $params = [
        'headers' => [
             'Authorization' => "Bearer {$token}",
         'query' => $query, 
         'json' => $json
    $res = json_decode($client->request('PUT', $api_url, $params)->getBody()->getContents());
    $shared_link = $res->shared_link->url;
    $download = $res->shared_link->download_url;
    Comment actions Permalink
  • kliger

     I have the same issue that you had, did you figure out how to create a curl request to do that?

    I am trying this one but it doesn't create a shared link correctly 😞


    curl -X PUT \
         -H 'Authorization: Bearer ' \
         -H 'Content-Type: "application/json"' \
         -d '{
           "shared_link": {
             "access": "open"
    Comment actions Permalink

Please sign in to leave a comment.