|
| 1 | +# Hostinger\MailAPITokensApi |
| 2 | + |
| 3 | +All URIs are relative to https://developers.hostinger.com, except if the operation defines another base path. |
| 4 | + |
| 5 | +| Method | HTTP request | Description | |
| 6 | +| ------------- | ------------- | ------------- | |
| 7 | +| [**createAPITokenV1()**](MailAPITokensApi.md#createAPITokenV1) | **POST** /api/mail/v1/orders/{orderId}/api-tokens | Create API token | |
| 8 | +| [**listAPITokensV1()**](MailAPITokensApi.md#listAPITokensV1) | **GET** /api/mail/v1/api-tokens | List API tokens | |
| 9 | +| [**revokeAPITokenV1()**](MailAPITokensApi.md#revokeAPITokenV1) | **DELETE** /api/mail/v1/api-tokens/{tokenId} | Revoke API token | |
| 10 | + |
| 11 | + |
| 12 | +## `createAPITokenV1()` |
| 13 | + |
| 14 | +```php |
| 15 | +createAPITokenV1($orderId, $mailV1SchemaCreateApiTokenRequestSchema): \Hostinger\Model\MailV1ApiTokensApiTokenCreatedResource |
| 16 | +``` |
| 17 | + |
| 18 | +Create API token |
| 19 | + |
| 20 | +Create an API token for the given mail order. The token grants access to the [Hostinger Email API](https://api.mail.hostinger.com/), where you can provision and manage the mailboxes it is scoped to. The plaintext token is returned only in this response, never again. A maximum of 10 tokens can exist per order. Use `scope.has_all_mailboxes` to cover all current and future mailboxes, or list specific mailboxes in `scope.mailbox_ids`. |
| 21 | + |
| 22 | +### Example |
| 23 | + |
| 24 | +```php |
| 25 | +<?php |
| 26 | +require_once(__DIR__ . '/vendor/autoload.php'); |
| 27 | + |
| 28 | + |
| 29 | +// Configure Bearer authorization: apiToken |
| 30 | +$config = Hostinger\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); |
| 31 | + |
| 32 | + |
| 33 | +$apiInstance = new Hostinger\Api\MailAPITokensApi(config: $config); |
| 34 | +$orderId = OR1a2b3c4d5e6f7g; // string | Order resource ID |
| 35 | +$mailV1SchemaCreateApiTokenRequestSchema = new \Hostinger\Model\MailV1SchemaCreateApiTokenRequestSchema(); // \Hostinger\Model\MailV1SchemaCreateApiTokenRequestSchema |
| 36 | + |
| 37 | +try { |
| 38 | + $result = $apiInstance->createAPITokenV1($orderId, $mailV1SchemaCreateApiTokenRequestSchema); |
| 39 | + print_r($result); |
| 40 | +} catch (Exception $e) { |
| 41 | + echo 'Exception when calling MailAPITokensApi->createAPITokenV1: ', $e->getMessage(), PHP_EOL; |
| 42 | +} |
| 43 | +``` |
| 44 | + |
| 45 | +### Parameters |
| 46 | + |
| 47 | +| Name | Type | Description | Notes | |
| 48 | +| ------------- | ------------- | ------------- | ------------- | |
| 49 | +| **orderId** | **string**| Order resource ID | | |
| 50 | +| **mailV1SchemaCreateApiTokenRequestSchema** | [**\Hostinger\Model\MailV1SchemaCreateApiTokenRequestSchema**](../Model/MailV1SchemaCreateApiTokenRequestSchema.md)| | | |
| 51 | + |
| 52 | +### Return type |
| 53 | + |
| 54 | +[**\Hostinger\Model\MailV1ApiTokensApiTokenCreatedResource**](../Model/MailV1ApiTokensApiTokenCreatedResource.md) |
| 55 | + |
| 56 | +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) |
| 57 | +[[Back to Model list]](../../README.md#models) |
| 58 | +[[Back to README]](../../README.md) |
| 59 | + |
| 60 | +## `listAPITokensV1()` |
| 61 | + |
| 62 | +```php |
| 63 | +listAPITokensV1($orderId, $page, $perPage): \Hostinger\Model\MailListAPITokensV1200Response |
| 64 | +``` |
| 65 | + |
| 66 | +List API tokens |
| 67 | + |
| 68 | +Retrieve a paginated list of [Hostinger Email API](https://api.mail.hostinger.com/) tokens across all your mail orders, optionally filtered by order. Plaintext tokens are never included; they are returned only when a token is created. |
| 69 | + |
| 70 | +### Example |
| 71 | + |
| 72 | +```php |
| 73 | +<?php |
| 74 | +require_once(__DIR__ . '/vendor/autoload.php'); |
| 75 | + |
| 76 | + |
| 77 | +// Configure Bearer authorization: apiToken |
| 78 | +$config = Hostinger\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); |
| 79 | + |
| 80 | + |
| 81 | +$apiInstance = new Hostinger\Api\MailAPITokensApi(config: $config); |
| 82 | +$orderId = OR1a2b3c4d5e6f7g,OR9z8y7x6w5v4u3t; // string | Filter tokens by order resource ID. Single value or comma-separated list. |
| 83 | +$page = 1; // int | Page number |
| 84 | +$perPage = 25; // int | Number of items per page |
| 85 | + |
| 86 | +try { |
| 87 | + $result = $apiInstance->listAPITokensV1($orderId, $page, $perPage); |
| 88 | + print_r($result); |
| 89 | +} catch (Exception $e) { |
| 90 | + echo 'Exception when calling MailAPITokensApi->listAPITokensV1: ', $e->getMessage(), PHP_EOL; |
| 91 | +} |
| 92 | +``` |
| 93 | + |
| 94 | +### Parameters |
| 95 | + |
| 96 | +| Name | Type | Description | Notes | |
| 97 | +| ------------- | ------------- | ------------- | ------------- | |
| 98 | +| **orderId** | **string**| Filter tokens by order resource ID. Single value or comma-separated list. | [optional] | |
| 99 | +| **page** | **int**| Page number | [optional] | |
| 100 | +| **perPage** | **int**| Number of items per page | [optional] [default to 25] | |
| 101 | + |
| 102 | +### Return type |
| 103 | + |
| 104 | +[**\Hostinger\Model\MailListAPITokensV1200Response**](../Model/MailListAPITokensV1200Response.md) |
| 105 | + |
| 106 | +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) |
| 107 | +[[Back to Model list]](../../README.md#models) |
| 108 | +[[Back to README]](../../README.md) |
| 109 | + |
| 110 | +## `revokeAPITokenV1()` |
| 111 | + |
| 112 | +```php |
| 113 | +revokeAPITokenV1($tokenId): \Hostinger\Model\CommonSuccessEmptyResource |
| 114 | +``` |
| 115 | + |
| 116 | +Revoke API token |
| 117 | + |
| 118 | +Revoke an API token. The token immediately loses access to the [Hostinger Email API](https://api.mail.hostinger.com/). This action cannot be undone. |
| 119 | + |
| 120 | +### Example |
| 121 | + |
| 122 | +```php |
| 123 | +<?php |
| 124 | +require_once(__DIR__ . '/vendor/autoload.php'); |
| 125 | + |
| 126 | + |
| 127 | +// Configure Bearer authorization: apiToken |
| 128 | +$config = Hostinger\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); |
| 129 | + |
| 130 | + |
| 131 | +$apiInstance = new Hostinger\Api\MailAPITokensApi(config: $config); |
| 132 | +$tokenId = 019683f8-1234-7abc-8def-0123456789ab; // string | API token ID (returned when the token was created) |
| 133 | + |
| 134 | +try { |
| 135 | + $result = $apiInstance->revokeAPITokenV1($tokenId); |
| 136 | + print_r($result); |
| 137 | +} catch (Exception $e) { |
| 138 | + echo 'Exception when calling MailAPITokensApi->revokeAPITokenV1: ', $e->getMessage(), PHP_EOL; |
| 139 | +} |
| 140 | +``` |
| 141 | + |
| 142 | +### Parameters |
| 143 | + |
| 144 | +| Name | Type | Description | Notes | |
| 145 | +| ------------- | ------------- | ------------- | ------------- | |
| 146 | +| **tokenId** | **string**| API token ID (returned when the token was created) | | |
| 147 | + |
| 148 | +### Return type |
| 149 | + |
| 150 | +[**\Hostinger\Model\CommonSuccessEmptyResource**](../Model/CommonSuccessEmptyResource.md) |
| 151 | + |
| 152 | +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) |
| 153 | +[[Back to Model list]](../../README.md#models) |
| 154 | +[[Back to README]](../../README.md) |
0 commit comments