Crear Clave API

Genera una nueva clave API para autenticación.

POST/api-keys

Cuerpo de la Solicitud

namestringRequired

El nombre de la clave API para identificación.

scopestring

El alcance de la clave API. Puede ser ‘full’ o ‘sending’ (por defecto: ‘full’).

sending_domain_idinteger

El ID del dominio de envío al que restringir esta clave (por defecto: 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: 'Mi Clave 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' => 'Mi Clave 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 "Error 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': 'Mi Clave 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: 'Mi Clave 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": "Mi Clave 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": "Mi Clave 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\":\"Mi Clave 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 = "Mi Clave 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": "Mi Clave API",
"scope": "sending",
"sending_domain_id": 1234567890
}'
{
"object": "api_key",
"id": 1234567890,
"name": "Mi Clave 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": "Solicitud Incorrecta"
}
}
{
"error": {
"code": 409,
"message": "La clave API ya existe"
},
"existing": {
"object": "api_key",
"id": 1234567890,
"name": "Mi Clave API"
}
}

Obtener Clave API

Consulta la información de una clave API específica en tu cuenta de Emailit.

GET/api-keys/{id}

Parámetros de Ruta

idstringRequired

El ID de la clave API que deseas consultar.

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 "Error 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": "Mi Clave 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": "Clave API no encontrada"
}
}

Listar Claves API

Obtén todas las claves API de tu cuenta.

GET/api-keys

Parámetros de Consulta

pageinteger

Número de página para la paginación (mínimo: 1).

limitinteger

Cantidad de claves API a devolver (mínimo: 1, máximo: 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 "Error 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": "Mi Clave 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": "Otra Clave 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
}

Actualizar Clave API

Actualiza el nombre de una clave API existente en tu cuenta de Emailit.

POST/api-keys/{id}

Parámetros de Ruta

idstringRequired

El ID de la clave API que deseas actualizar.

Cuerpo de la Solicitud

namestringRequired

El nuevo nombre para la clave 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: 'Nombre Actualizado de Clave 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' => 'Nombre Actualizado de Clave 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 "Error 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': 'Nombre Actualizado de Clave 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: 'Nombre Actualizado de Clave 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": "Nombre Actualizado de Clave 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": "Nombre Actualizado de Clave 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\":\"Nombre Actualizado de Clave 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\":\"Nombre Actualizado de Clave 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": "Nombre Actualizado de Clave API"
}'
{
"object": "api_key",
"id": 1234567890,
"name": "Nombre Actualizado de Clave 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": "Solicitud incorrecta"
}
}
{
"error": {
"code": 404,
"message": "Clave API no encontrada"
}
}
{
"error": {
"code": 409,
"message": "El nombre de la clave API ya existe"
}
}

Eliminar Clave API

Revoca y elimina una clave API de tu cuenta de Emailit.

DELETE/api-keys/{id}

Parámetros de Ruta

idstringRequired

El ID de la clave API que deseas eliminar.

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 "Error 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("Estado:", 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!("Estado: {}", 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("Estado: " + 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("Estado: " + 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": "Mi Clave API",
"deleted": true
}
{
"error": {
"code": 404,
"message": "Clave API no encontrada"
}
}
Localizado por IA