Usage a smtp credential
/api/v1/smtp-credentials/{credential}/usageParameters
| Name | In | Type | Description |
|---|---|---|---|
credentialrequired | path | string | The credential identifier. |
Request
/api/v1/smtp-credentials/{credential}/usagecurl -X GET 'https://app.mailyte.com/api/v1/smtp-credentials/01JBT8XQ2M9WYC3K4F6R7S8T9V/usage' \
-H 'Authorization: Bearer mk_live_YOUR_API_KEY'const response = await fetch('https://app.mailyte.com/api/v1/smtp-credentials/01JBT8XQ2M9WYC3K4F6R7S8T9V/usage', {
method: 'GET',
headers: {
Authorization: 'Bearer mk_live_YOUR_API_KEY',
},
});
const { data } = await response.json();import requests
response = requests.get(
"https://app.mailyte.com/api/v1/smtp-credentials/01JBT8XQ2M9WYC3K4F6R7S8T9V/usage",
headers={"Authorization": "Bearer mk_live_YOUR_API_KEY"},
)
data = response.json()["data"]<?php
$response = Http::withToken('mk_live_YOUR_API_KEY')
->get('https://app.mailyte.com/api/v1/smtp-credentials/01JBT8XQ2M9WYC3K4F6R7S8T9V/usage');
$data = $response->json('data');require "net/http"
require "json"
uri = URI("https://app.mailyte.com/api/v1/smtp-credentials/01JBT8XQ2M9WYC3K4F6R7S8T9V/usage")
request = Net::HTTP::Get.new(uri)
request["Authorization"] = "Bearer mk_live_YOUR_API_KEY"
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }Response
Success.
dataobjectobjectstringsmtp_credential_usagewindowobjectThe period these counts cover, stated in full so you do not have to infer the end from the start.
daysintegerLength of the window in days.
sincestringISO 8601 UTC, normalised here: the mail server reports this without a timezone, which a naive parser reads as local time. **null means UNKNOWN -- there is no window, because the mail server was never asked.** That is the `counted: false` case: an unprovisioned credential is answered locally and the local answer has no start date to give. It does not mean "since the beginning of time", and it is not an open range you may substitute one for. `days` still reports the length you requested even then, so `days` being populated is no evidence that a window was actually measured -- `since` and `counted` are.
untilstringISO 8601 UTC. The moment the counts were computed against.
countedbooleanWhether the counts below mean anything. **false when the credential is not provisioned on the mail server**, in which case every count is null rather than zero -- it has never sent, which is not the same as having sent and delivered nothing. Read the true case narrowly: `counted: true` says the mail server was asked and answered, not that every count came back populated. A null count still means unknown even here.
totalintegerMessages attempted with this credential. Credential-scoped. **null means UNKNOWN, not zero** -- we did not get a number, rather than getting the number nought. Zero is a real answer and is returned as `0`. Two things produce the null: `counted: false`, meaning the credential is not provisioned on the mail server so it was never asked; or the mail server answering without this particular field, which is rare and is still not a licence to read it as 0. Never sum or average across a null -- an unknown treated as zero is how a bill gets computed from a meter nobody read.
deliveredintegerAccepted by the receiving server. Credential-scoped. **null means UNKNOWN, not zero** -- we did not get a number, rather than getting the number nought. Zero is a real answer and is returned as `0`. Two things produce the null: `counted: false`, meaning the credential is not provisioned on the mail server so it was never asked; or the mail server answering without this particular field, which is rare and is still not a licence to read it as 0. Never sum or average across a null -- an unknown treated as zero is how a bill gets computed from a meter nobody read.
bouncedintegerPermanently rejected. Credential-scoped. **null means UNKNOWN, not zero** -- we did not get a number, rather than getting the number nought. Zero is a real answer and is returned as `0`. Two things produce the null: `counted: false`, meaning the credential is not provisioned on the mail server so it was never asked; or the mail server answering without this particular field, which is rare and is still not a licence to read it as 0. Never sum or average across a null -- an unknown treated as zero is how a bill gets computed from a meter nobody read.
deferredintegerTemporarily rejected and retried. Credential-scoped. **null means UNKNOWN, not zero** -- we did not get a number, rather than getting the number nought. Zero is a real answer and is returned as `0`. Two things produce the null: `counted: false`, meaning the credential is not provisioned on the mail server so it was never asked; or the mail server answering without this particular field, which is rare and is still not a licence to read it as 0. Never sum or average across a null -- an unknown treated as zero is how a bill gets computed from a meter nobody read.
rejectedintegerRefused by us before submission. Credential-scoped. **null means UNKNOWN, not zero** -- we did not get a number, rather than getting the number nought. Zero is a real answer and is returned as `0`. Two things produce the null: `counted: false`, meaning the credential is not provisioned on the mail server so it was never asked; or the mail server answering without this particular field, which is rare and is still not a licence to read it as 0. Never sum or average across a null -- an unknown treated as zero is how a bill gets computed from a meter nobody read.
last_used_atstringISO 8601 UTC. **null means the mail server has no record of this credential ever authenticating** -- NONE, and lifetime, not "unused during this window". Unlike the `last_used_at` on the credential itself, this one is read from the mail server at request time rather than from an hourly mirror, so it is the fresher of the two and the one to trust when they disagree. The one exception is `counted: false`: the mail server was never asked, so null there is unknown rather than never.
Returned inside the standard envelope.
Errors
| Status | When |
|---|---|
401 | The API key is missing, unknown, revoked or expired. All four answer identically, on purpose: distinguishing them would confirm which keys exist. |
403 | The key is valid but may not do this: it lacks the required scope, its IP allowlist does not include you, or this endpoint does not accept API keys. |
404 | No such resource in this organization. |
422 | The request was understood but the values were not acceptable. |
429 | Too many requests, or the organization has spent its sending allowance. `Retry-After` says how long to wait. |
Every status, with what causes it and what to do, is on the error reference.