The first step is to obtain a token. Tokens are required to make subsequent API calls. To obtain your token, you simply have to call the Create a token endpoint along with your Cakemail username and password.
# you may have to install `requests`: python -m pip install requestsimport requestsurl = "https://api.cakemail.dev/token"username = "email@address.com"password = "yourpassword"payload = { "grant_type": "password", "username": username, "password": password}headers = { "accept": "application/json", "content-type": "application/x-www-form-urlencoded"}response = requests.post(url, data=payload, headers=headers)print(response.text)
python
<?php// you may have to install `guzzle`: composer require guzzlehttp/guzzlerequire_once('vendor/autoload.php');$client = new \GuzzleHttp\Client();$response = $client->request('POST', 'https://api.cakemail.dev/token', [ 'form_params' => [ 'grant_type' => 'password', 'username' => 'email@address.com',. 'password' => 'yourpassword' ], 'headers' => [ 'accept' => 'application/json', 'content-type' => 'application/x-www-form-urlencoded', ],]);echo $response->getBody();
This call, if successful, will return you a valid token containing:
Access Token
Token Type
Expires In
Refresh Token
The Access Token is what you will need to make the next API call. Before you can send your first email, you will need to create and confirm your first Sender. This step is required so we can make sure you have access to the mailbox of that sender.
To use a sender, it must be confirmed. If the sender email address is the same as your login email address, the sender will automatically be confirmed.
Otherwise, a confirmation email is sent to the sender email address; simply click the activation link to confirm your sender.