Crea Chiave API
Genera una nuova chiave API per l’autenticazione.
/api-keysCorpo della Richiesta
namestringRequiredIl nome della chiave API per l’identificazione.
scopestringL’ambito della chiave API. Può essere ‘full’ o ‘sending’ (predefinito: ‘full’).
sending_domain_idintegerL’ID del dominio di invio a cui limitare questa chiave (predefinito: 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: 'La Mia Chiave 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' => 'La Mia Chiave 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 "Errore 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': 'La Mia Chiave 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: 'La Mia Chiave 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": "La Mia Chiave 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": "La Mia Chiave 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\":\"La Mia Chiave 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 = "La Mia Chiave 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": "La Mia Chiave API",
"scope": "sending",
"sending_domain_id": 1234567890
}' {
"object": "api_key",
"id": 1234567890,
"name": "La Mia Chiave 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": "Richiesta non valida"
}
} {
"error": {
"code": 409,
"message": "La chiave API esiste già"
},
"existing": {
"object": "api_key",
"id": 1234567890,
"name": "La Mia Chiave API"
}
} Ottieni Chiave API
Recupera le informazioni relative a una specifica chiave API nel tuo account Emailit.
/api-keys/{id}Parametri del Percorso
idstringRequiredL’ID della chiave API da recuperare.
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 "Errore 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": "La Mia Chiave 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": "Chiave API non trovata"
}
} Elencare le Chiavi API
Ottieni tutte le chiavi API del tuo account.
/api-keysParametri di Query
pageintegerNumero di pagina per la paginazione (minimo: 1).
limitintegerNumero di chiavi API da restituire (minimo: 1, massimo: 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 "Errore 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": "La Mia Chiave 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": "Un'Altra Chiave 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
} Aggiorna Chiave API
Aggiorna il nome di una chiave API esistente nel tuo account Emailit.
/api-keys/{id}Parametri del Percorso
idstringRequiredL’ID della chiave API da aggiornare.
Corpo della Richiesta
namestringRequiredIl nuovo nome per la chiave 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: 'Nome Chiave API Aggiornato'
})
});
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' => 'Nome Chiave API Aggiornato'
]),
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 "Errore 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': 'Nome Chiave API Aggiornato'
},
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: 'Nome Chiave API Aggiornato'
}.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": "Nome Chiave API Aggiornato",
}
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": "Nome Chiave API Aggiornato"
}))
.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\":\"Nome Chiave API Aggiornato\"}";
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\":\"Nome Chiave API Aggiornato\"}";
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": "Nome Chiave API Aggiornato"
}' {
"object": "api_key",
"id": 1234567890,
"name": "Nome Chiave API Aggiornato",
"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": "Richiesta non valida"
}
} {
"error": {
"code": 404,
"message": "Chiave API non trovata"
}
} {
"error": {
"code": 409,
"message": "Il nome della chiave API esiste già"
}
} Elimina Chiave API
Revoca ed elimina una chiave API dal tuo account Emailit.
/api-keys/{id}Parametri del Percorso
idstringRequiredL’ID della chiave API da eliminare.
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 "Errore 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("Stato:", 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!("Stato: {}", 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("Stato: " + 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("Stato: " + 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": "La Mia Chiave API",
"deleted": true
} {
"error": {
"code": 404,
"message": "Chiave API non trovata"
}
}