Smtp Token CallBacks

Create Smtp Token

Overview

Generates a new API token for programmatic access to SendClean APIs. API tokens provide:

  • Secure authentication without passwords
  • Ability to revoke access without changing passwords
  • Granular permission control
  • Audit trails of token usage

Best practices:

  • Create separate tokens for each application
  • Rotate tokens every 90 days
  • Never commit tokens to source control
  • Use environment variables for token storage
  • Monitor token usage for anomalies

Endpoint Details

HTTP MethodPOST
Endpoint Path/v2/apiKey/create
API VersionBulk API (v2.0)
Content-Typeapplication/json

Request Parameters

ParameterTypeRequiredDescriptionExample
owner_idStringYesYour unique SendClean account identifieruser_12345

Request Example

Below is a complete example of the request body. Replace placeholder values with your actual credentials and data.

{
  "owner_id": "{{owner_id}}",
  "smtp": "{{smtp_user_name}}"
}

Response Format

Successful Response:

{
    "status": "success",
    "code": 200,
    "message": "Resource created successfully",
    "data": {
        "id": "resource_abc123",
        "created_at": "2026-04-17T10:30:00Z"
    }
}

Common Errors & Troubleshooting

401 - Unauthorized: Authentication credentials are missing or invalid

Solution: Verify owner_id and token are correct. Ensure they match your account credentials exactly with no extra whitespace.

500 - Internal server error: Unexpected server error occurred

Solution: Retry the request after a brief delay. If error persists, contact SendClean support with the request details and timestamp.

Implementation Examples

curl -X POST \
  https://api.sendclean.com/v2/apiKey/create \
  -H 'Content-Type: application/json' \
  -d '{
  "owner_id": "{{owner_id}}",
  "smtp": "{{smtp_user_name}}"
}'
const axios = require('axios');

const url = 'https://api.sendclean.com/v2/apiKey/create';

const payload = {
    "owner_id":"{{owner_id}}",
    "smtp":"{{smtp_user_name}}"
};

axios.post(url, payload, {
    headers: {
        'Content-Type': 'application/json'
    }
})
.then(response => {
    console.log('Success:', response.data);
})
.catch(error => {
    console.error('Error:', error.response ? error.response.data : error.message);
});
<?php

$url = 'https://api.sendclean.com/v2/apiKey/create';

$payload = json_decode('{
    "owner_id":"{{owner_id}}",
    "smtp":"{{smtp_user_name}}"
}', true);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json'
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode == 200) {
    $result = json_decode($response, true);
    print_r($result);
} else {
    echo "Error: $httpCode - $response";
}

?>

Get Smtp Token

Overview

Retrieves existing API tokens for your SMTP users. The response includes:

  • Token identifiers (not full tokens for security)
  • Creation date and last used date
  • Associated permissions
  • Usage statistics
  • Active/inactive status

Use this to:

  • Audit which tokens are active
  • Identify unused tokens for cleanup
  • Monitor token usage patterns
  • Plan token rotation schedules

Endpoint Details

HTTP MethodPOST
Endpoint Path/v2/apiKey/get
API VersionBulk API (v2.0)
Content-Typeapplication/json

Request Parameters

ParameterTypeRequiredDescriptionExample
owner_idStringYesYour unique SendClean account identifieruser_12345

Request Example

Below is a complete example of the request body. Replace placeholder values with your actual credentials and data.

{
  "owner_id": "{{owner_id}}",
  "smtp": "{{smtp_user_name}}"
}

Response Format

Successful Response:

{
    "status": "success",
    "code": 200,
    "message": "Operation completed successfully"
}

Common Errors & Troubleshooting

401 - Unauthorized: Authentication credentials are missing or invalid

Solution: Verify owner_id and token are correct. Ensure they match your account credentials exactly with no extra whitespace.

500 - Internal server error: Unexpected server error occurred

Solution: Retry the request after a brief delay. If error persists, contact SendClean support with the request details and timestamp.

Implementation Examples

curl -X POST \
  https://api.sendclean.com/v2/apiKey/get \
  -H 'Content-Type: application/json' \
  -d '{
  "owner_id": "{{owner_id}}",
  "smtp": "{{smtp_user_name}}"
}'
const axios = require('axios');

const url = 'https://api.sendclean.com/v2/apiKey/get';

const payload = {
    "owner_id": "{{owner_id}}",
    "smtp": "{{smtp_user_name}}"
};

axios.post(url, payload, {
    headers: {
        'Content-Type': 'application/json'
    }
})
.then(response => {
    console.log('Success:', response.data);
})
.catch(error => {
    console.error('Error:', error.response ? error.response.data : error.message);
});
<?php

$url = 'https://api.sendclean.com/v2/apiKey/get';

$payload = json_decode('{
    "owner_id": "{{owner_id}}",
    "smtp": "{{smtp_user_name}}"
}', true);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json'
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode == 200) {
    $result = json_decode($response, true);
    print_r($result);
} else {
    echo "Error: $httpCode - $response";
}

?>

Update Smtp Token

Overview

Modifies an existing API token's configuration including:

  • Permissions and scopes
  • Active/inactive status
  • Description and metadata
  • Expiration settings

Common updates:

  • Restricting permissions after security review
  • Temporarily disabling tokens during incidents
  • Updating descriptions for better organization
  • Setting expiration dates for automatic rotation

Endpoint Details

HTTP MethodPOST
Endpoint Path/v2/apiKey/update
API VersionBulk API (v2.0)
Content-Typeapplication/json

Request Parameters

ParameterTypeRequiredDescriptionExample
owner_idStringYesYour unique SendClean account identifieruser_12345

Request Example

Below is a complete example of the request body. Replace placeholder values with your actual credentials and data.

{
  "owner_id": "{{owner_id}}",
  "smtp": "{{smtp_user_name}}"
}

Response Format

Successful Response:

{
    "status": "success",
    "code": 200,
    "message": "Resource updated successfully",
    "data": {
        "updated_at": "2026-04-17T10:30:00Z"
    }
}

Common Errors & Troubleshooting

401 - Unauthorized: Authentication credentials are missing or invalid

Solution: Verify owner_id and token are correct. Ensure they match your account credentials exactly with no extra whitespace.

500 - Internal server error: Unexpected server error occurred

Solution: Retry the request after a brief delay. If error persists, contact SendClean support with the request details and timestamp.

Implementation Examples

curl -X POST \
  https://api.sendclean.com/v2/apiKey/update \
  -H 'Content-Type: application/json' \
  -d '{
  "owner_id": "{{owner_id}}",
  "smtp": "{{smtp_user_name}}"
}'
const axios = require('axios');

const url = 'https://api.sendclean.com/v2/apiKey/update';

const payload = {
    "owner_id": "{{owner_id}}",
    "smtp": "{{smtp_user_name}}"
};

axios.post(url, payload, {
    headers: {
        'Content-Type': 'application/json'
    }
})
.then(response => {
    console.log('Success:', response.data);
})
.catch(error => {
    console.error('Error:', error.response ? error.response.data : error.message);
});
<?php

$url = 'https://api.sendclean.com/v2/apiKey/update';

$payload = json_decode('{
    "owner_id": "{{owner_id}}",
    "smtp": "{{smtp_user_name}}"
}', true);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json'
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode == 200) {
    $result = json_decode($response, true);
    print_r($result);
} else {
    echo "Error: $httpCode - $response";
}

?>

Did this page help you?