Створення API ключа

Створіть новий API ключ для автентифікації.

POST/api-keys

Тіло запиту

namestringRequired

Назва API ключа для ідентифікації.

scopestring

Область дії API ключа. Може бути ‘full’ або ‘sending’ (за замовчуванням: ‘full’).

sending_domain_idinteger

ID домену відправлення для обмеження цього ключа (за замовчуванням: null).

const response = await fetch('https://api.emailit.com/v2/api-keys', {
method: 'POST',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Мій API ключ',
scope: 'sending',
sending_domain_id: 1234567890
})
});

const result = await response.json();
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.emailit.com/v2/api-keys',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Мій API ключ',
'scope' => 'sending',
'sending_domain_id' => 1234567890
]),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type: application/json'
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "Помилка cURL #:" . $err;
} else {
$result = json_decode($response, true);
print_r($result);
}
import requests

response = requests.post(
'https://api.emailit.com/v2/api-keys',
headers={
    'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
    'Content-Type': 'application/json'
},
json={
    'name': 'Мій API ключ',
    'scope': 'sending',
    'sending_domain_id': 1234567890
}
)

result = response.json()
print(result)
require 'net/http'
require 'json'

uri = URI('https://api.emailit.com/v2/api-keys')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer em_test_51RxCWJ...vS00p61e0qRE'
request['Content-Type'] = 'application/json'
request.body = {
name: 'Мій API ключ',
scope: 'sending',
sending_domain_id: 1234567890
}.to_json

response = http.request(request)
result = JSON.parse(response.body)
puts result
package main

import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)

func main() {
url := "https://api.emailit.com/v2/api-keys"

data := map[string]interface{}{
    "name": "Мій API ключ",
    "scope": "sending",
    "sending_domain_id": 1234567890,
}

jsonData, _ := json.Marshal(data)

req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
req.Header.Set("Content-Type", "application/json")

client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()

var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
}
use reqwest;
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();

let response = client
    .post("https://api.emailit.com/v2/api-keys")
    .header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
    .header("Content-Type", "application/json")
    .json(&json!({
        "name": "Мій API ключ",
        "scope": "sending",
        "sending_domain_id": 1234567890
    }))
    .send()
    .await?;

let result: Value = response.json().await?;
println!("{:?}", result);

Ok(())
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.http.HttpRequest.BodyPublishers;

public class CreateApiKey {
public static void main(String[] args) throws Exception {
    HttpClient client = HttpClient.newHttpClient();
    
    String jsonBody = "{\"name\":\"Мій API ключ\",\"scope\":\"sending\",\"sending_domain_id\":1234567890}";
    
    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://api.emailit.com/v2/api-keys"))
        .header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
        .header("Content-Type", "application/json")
        .POST(BodyPublishers.ofString(jsonBody))
        .build();
    
    HttpResponse<String> response = client.send(request, 
        HttpResponse.BodyHandlers.ofString());
    
    System.out.println(response.body());
}
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

public class CreateApiKey
{
public static async Task Main()
{
    using (var client = new HttpClient())
    {
        client.DefaultRequestHeaders.Add("Authorization", 
            "Bearer em_test_51RxCWJ...vS00p61e0qRE");
        
        var data = new { name = "Мій API ключ", scope = "sending", sending_domain_id = 1234567890 };
        var json = JsonConvert.SerializeObject(data);
        var content = new StringContent(json, Encoding.UTF8, "application/json");
        
        var response = await client.PostAsync(
            "https://api.emailit.com/v2/api-keys", content);
        
        var result = await response.Content.ReadAsStringAsync();
        Console.WriteLine(result);
    }
}
}
curl -X POST https://api.emailit.com/v2/api-keys \
-H "Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE" \
-H "Content-Type: application/json" \
-d '{
"name": "Мій API ключ",
"scope": "sending",
"sending_domain_id": 1234567890
}'
{
"object": "api_key",
"id": 1234567890,
"name": "Мій API ключ",
"scope": "sending",
"sending_domain_id": 1234567890,
"last_used_at": null,
"created_at": "2021-01-01T00:00:00Z",
"updated_at": "2021-01-01T00:00:00Z",
"key": "em_live_51RxCWJ...vS00p61e0qRE"
}
{
"error": {
"code": 400,
"message": "Неправильний запит"
}
}
{
"error": {
"code": 409,
"message": "API ключ вже існує"
},
"existing": {
"object": "api_key",
"id": 1234567890,
"name": "Мій API ключ"
}
}

Отримати API ключ

Отримайте інформацію про конкретний API ключ у вашому акаунті Emailit.

GET/api-keys/{id}

Параметри шляху

idstringRequired

Ідентифікатор API ключа, який потрібно отримати.

const response = await fetch('https://api.emailit.com/v2/api-keys/ak_1234567890', {
method: 'GET',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
}
});

const result = await response.json();
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.emailit.com/v2/api-keys/ak_1234567890',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type: application/json'
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "Помилка cURL #:" . $err;
} else {
$result = json_decode($response, true);
print_r($result);
}
import requests

response = requests.get(
'https://api.emailit.com/v2/api-keys/ak_1234567890',
headers={
    'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
    'Content-Type': 'application/json'
}
)

result = response.json()
print(result)
require 'net/http'
require 'json'

uri = URI('https://api.emailit.com/v2/api-keys/ak_1234567890')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer em_test_51RxCWJ...vS00p61e0qRE'
request['Content-Type'] = 'application/json'

response = http.request(request)
result = JSON.parse(response.body)
puts result
package main

import (
"encoding/json"
"fmt"
"net/http"
)

func main() {
url := "https://api.emailit.com/v2/api-keys/ak_1234567890"

req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
req.Header.Set("Content-Type", "application/json")

client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()

var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
}
use reqwest;
use serde_json::Value;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();

let response = client
    .get("https://api.emailit.com/v2/api-keys/ak_1234567890")
    .header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
    .header("Content-Type", "application/json")
    .send()
    .await?;

let result: Value = response.json().await?;
println!("{:?}", result);

Ok(())
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;

public class GetApiKey {
public static void main(String[] args) throws Exception {
    HttpClient client = HttpClient.newHttpClient();
    
    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://api.emailit.com/v2/api-keys/ak_1234567890"))
        .header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
        .header("Content-Type", "application/json")
        .GET()
        .build();
    
    HttpResponse<String> response = client.send(request, 
        HttpResponse.BodyHandlers.ofString());
    
    System.out.println(response.body());
}
}
using System;
using System.Net.Http;
using System.Threading.Tasks;

public class GetApiKey
{
public static async Task Main()
{
    using (var client = new HttpClient())
    {
        client.DefaultRequestHeaders.Add("Authorization", 
            "Bearer em_test_51RxCWJ...vS00p61e0qRE");
        
        var response = await client.GetAsync(
            "https://api.emailit.com/v2/api-keys/ak_1234567890");
        
        var result = await response.Content.ReadAsStringAsync();
        Console.WriteLine(result);
    }
}
}
curl -X GET https://api.emailit.com/v2/api-keys/ak_1234567890 \
-H "Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE" \
-H "Content-Type: application/json"
{
"object": "api_key",
"id": 1234567890,
"name": "Мій API ключ",
"scope": "sending",
"sending_domain_id": 1234567890,
"last_used_at": "2021-01-01T12:00:00Z",
"created_at": "2021-01-01T00:00:00Z",
"updated_at": "2021-01-01T00:00:00Z"
}
{
"error": {
"code": 404,
"message": "API ключ не знайдено"
}
}

Список API ключів

Отримати всі API ключі у вашому акаунті.

GET/api-keys

Параметри запиту

pageinteger

Номер сторінки для пагінації (мінімум: 1).

limitinteger

Кількість API ключів для повернення (мінімум: 1, максимум: 100).

const response = await fetch('https://api.emailit.com/v2/api-keys?page=1&limit=10', {
method: 'GET',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
}
});

const result = await response.json();
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.emailit.com/v2/api-keys?page=1&limit=10',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type: application/json'
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "Помилка cURL #:" . $err;
} else {
$result = json_decode($response, true);
print_r($result);
}
import requests

response = requests.get(
'https://api.emailit.com/v2/api-keys',
params={
    'page': 1,
    'limit': 10
},
headers={
    'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
    'Content-Type': 'application/json'
}
)

result = response.json()
print(result)
require 'net/http'
require 'json'

uri = URI('https://api.emailit.com/v2/api-keys?page=1&limit=10')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer em_test_51RxCWJ...vS00p61e0qRE'
request['Content-Type'] = 'application/json'

response = http.request(request)
result = JSON.parse(response.body)
puts result
package main

import (
"encoding/json"
"fmt"
"net/http"
)

func main() {
url := "https://api.emailit.com/v2/api-keys?page=1&limit=10"

req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
req.Header.Set("Content-Type", "application/json")

client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()

var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
}
use reqwest;
use serde_json::Value;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();

let response = client
    .get("https://api.emailit.com/v2/api-keys")
    .query(&[("page", "1"), ("limit", "10")])
    .header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
    .header("Content-Type", "application/json")
    .send()
    .await?;

let result: Value = response.json().await?;
println!("{:?}", result);

Ok(())
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;

public class ListApiKeys {
public static void main(String[] args) throws Exception {
    HttpClient client = HttpClient.newHttpClient();

    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://api.emailit.com/v2/api-keys?page=1&limit=10"))
        .header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
        .header("Content-Type", "application/json")
        .GET()
        .build();

    HttpResponse<String> response = client.send(request,
        HttpResponse.BodyHandlers.ofString());

    System.out.println(response.body());
}
}
using System;
using System.Net.Http;
using System.Threading.Tasks;

public class ListApiKeys
{
public static async Task Main()
{
    using (var client = new HttpClient())
    {
        client.DefaultRequestHeaders.Add("Authorization",
            "Bearer em_test_51RxCWJ...vS00p61e0qRE");

        var response = await client.GetAsync(
            "https://api.emailit.com/v2/api-keys?page=1&limit=10");

        var result = await response.Content.ReadAsStringAsync();
        Console.WriteLine(result);
    }
}
}
curl -X GET "https://api.emailit.com/v2/api-keys?page=1&limit=10" \
-H "Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE" \
-H "Content-Type: application/json"
{
"data": [
{
  "id": 1234567890,
  "name": "Мій API ключ",
  "scope": "sending",
  "sending_domain_id": 1234567890,
  "last_used_at": "2021-01-01T12:00:00Z",
  "created_at": "2021-01-01T00:00:00Z",
  "updated_at": "2021-01-01T00:00:00Z"
},
{
  "id": 1234567891,
  "name": "Інший API ключ",
  "scope": "full",
  "sending_domain_id": null,
  "last_used_at": null,
  "created_at": "2021-01-02T00:00:00Z",
  "updated_at": "2021-01-02T00:00:00Z"
}
],
"next_page_url": "https://api.emailit.com/v2/api-keys?page=2&limit=10",
"previous_page_url": null
}

Оновлення API ключа

Оновіть назву існуючого API ключа у вашому акаунті Emailit.

POST/api-keys/{id}

Параметри шляху

idstringRequired

Ідентифікатор API ключа для оновлення.

Тіло запиту

namestringRequired

Нова назва для API ключа.

const response = await fetch('https://api.emailit.com/v2/api-keys/ak_1234567890', {
method: 'POST',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Оновлена назва API ключа'
})
});

const result = await response.json();
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.emailit.com/v2/api-keys/ak_1234567890',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Оновлена назва API ключа'
]),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type: application/json'
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "Помилка cURL #:" . $err;
} else {
$result = json_decode($response, true);
print_r($result);
}
import requests

response = requests.post(
'https://api.emailit.com/v2/api-keys/ak_1234567890',
json={
    'name': 'Оновлена назва API ключа'
},
headers={
    'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
    'Content-Type': 'application/json'
}
)

result = response.json()
print(result)
require 'net/http'
require 'json'

uri = URI('https://api.emailit.com/v2/api-keys/ak_1234567890')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer em_test_51RxCWJ...vS00p61e0qRE'
request['Content-Type'] = 'application/json'
request.body = {
name: 'Оновлена назва API ключа'
}.to_json

response = http.request(request)
result = JSON.parse(response.body)
puts result
package main

import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)

func main() {
url := "https://api.emailit.com/v2/api-keys/ak_1234567890"

data := map[string]string{
    "name": "Оновлена назва API ключа",
}

jsonData, _ := json.Marshal(data)

req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
req.Header.Set("Content-Type", "application/json")

client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()

var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
}
use reqwest;
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();

let response = client
    .post("https://api.emailit.com/v2/api-keys/ak_1234567890")
    .json(&json!({
        "name": "Оновлена назва API ключа"
    }))
    .header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
    .header("Content-Type", "application/json")
    .send()
    .await?;

let result: Value = response.json().await?;
println!("{:?}", result);

Ok(())
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;

public class UpdateApiKey {
public static void main(String[] args) throws Exception {
    HttpClient client = HttpClient.newHttpClient();

    String jsonBody = "{\"name\":\"Оновлена назва API ключа\"}";

    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://api.emailit.com/v2/api-keys/ak_1234567890"))
        .header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
        .header("Content-Type", "application/json")
        .POST(HttpRequest.BodyPublishers.ofString(jsonBody))
        .build();

    HttpResponse<String> response = client.send(request,
        HttpResponse.BodyHandlers.ofString());

    System.out.println(response.body());
}
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

public class UpdateApiKey
{
public static async Task Main()
{
    using (var client = new HttpClient())
    {
        client.DefaultRequestHeaders.Add("Authorization",
            "Bearer em_test_51RxCWJ...vS00p61e0qRE");

        var json = "{\"name\":\"Оновлена назва API ключа\"}";
        var content = new StringContent(json, Encoding.UTF8, "application/json");

        var response = await client.PostAsync(
            "https://api.emailit.com/v2/api-keys/ak_1234567890", content);

        var result = await response.Content.ReadAsStringAsync();
        Console.WriteLine(result);
    }
}
}
curl -X POST https://api.emailit.com/v2/api-keys/ak_1234567890 \
-H "Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE" \
-H "Content-Type: application/json" \
-d '{
"name": "Оновлена назва API ключа"
}'
{
"object": "api_key",
"id": 1234567890,
"name": "Оновлена назва API ключа",
"scope": "sending",
"sending_domain_id": 1234567890,
"last_used_at": "2021-01-01T12:00:00Z",
"created_at": "2021-01-01T00:00:00Z",
"updated_at": "2021-01-01T12:00:00Z"
}
{
"error": {
"code": 400,
"message": "Неправильний запит"
}
}
{
"error": {
"code": 404,
"message": "API ключ не знайдено"
}
}
{
"error": {
"code": 409,
"message": "Назва API ключа вже існує"
}
}

Видалення API ключа

Відкличте та видаліть API ключ з вашого облікового запису Emailit.

DELETE/api-keys/{id}

Параметри шляху

idstringRequired

Ідентифікатор API ключа для видалення.

const response = await fetch('https://api.emailit.com/v2/api-keys/ak_1234567890', {
method: 'DELETE',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
}
});

const result = await response.json();
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.emailit.com/v2/api-keys/ak_1234567890',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type: application/json'
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "Помилка cURL #:" . $err;
} else {
$result = json_decode($response, true);
print_r($result);
}
import requests

response = requests.delete(
'https://api.emailit.com/v2/api-keys/ak_1234567890',
headers={
    'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
    'Content-Type': 'application/json'
}
)

result = response.json()
print(result)
require 'net/http'
require 'json'

uri = URI('https://api.emailit.com/v2/api-keys/ak_1234567890')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Delete.new(uri)
request['Authorization'] = 'Bearer em_test_51RxCWJ...vS00p61e0qRE'
request['Content-Type'] = 'application/json'

response = http.request(request)
result = JSON.parse(response.body)
puts result
package main

import (
"fmt"
"net/http"
)

func main() {
url := "https://api.emailit.com/v2/api-keys/ak_1234567890"

req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Set("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
req.Header.Set("Content-Type", "application/json")

client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()

fmt.Println("Статус:", resp.Status)
}
use reqwest;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();

let response = client
    .delete("https://api.emailit.com/v2/api-keys/ak_1234567890")
    .header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
    .header("Content-Type", "application/json")
    .send()
    .await?;

println!("Статус: {}", response.status());

Ok(())
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;

public class DeleteApiKey {
public static void main(String[] args) throws Exception {
    HttpClient client = HttpClient.newHttpClient();
    
    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://api.emailit.com/v2/api-keys/ak_1234567890"))
        .header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
        .header("Content-Type", "application/json")
        .DELETE()
        .build();
    
    HttpResponse<String> response = client.send(request, 
        HttpResponse.BodyHandlers.ofString());
    
    System.out.println("Статус: " + response.statusCode());
}
}
using System;
using System.Net.Http;
using System.Threading.Tasks;

public class DeleteApiKey
{
public static async Task Main()
{
    using (var client = new HttpClient())
    {
        client.DefaultRequestHeaders.Add("Authorization", 
            "Bearer em_test_51RxCWJ...vS00p61e0qRE");
        
        var response = await client.DeleteAsync(
            "https://api.emailit.com/v2/api-keys/ak_1234567890");
        
        Console.WriteLine("Статус: " + response.StatusCode);
    }
}
}
curl -X DELETE https://api.emailit.com/v2/api-keys/ak_1234567890 \
-H "Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE" \
-H "Content-Type: application/json"
{
"object": "api_key",
"id": 1234567890,
"name": "Мій API ключ",
"deleted": true
}
{
"error": {
"code": 404,
"message": "API ключ не знайдено"
}
}
Локалізовано за допомогою ШІ