To obtain a Shiptheory API Token you'll need to run the below script, bear in mind that authentication tokens expire after 60 minutes.


<?php

$data = json_encode(
    array(

        "email" => "youremail@email.com",

        "password" => "yourpassword"

    )
);

$ch = curl_init('https://api.shiptheory.com/v1/token');

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(

    'Accept: application/json',

    'Content-Type: application/json',

    'Content-Length: ' . strlen($data))
);

$result = curl_exec($ch);
curl_close($ch);

echo $result;

?>


Within the response will either be an error or the API token you'll need to make any other requests through Shiptheory, if you have any questions about this, feel free to contact support and we'll be happy to help or take a read through our API documentation