Create Logger API Key

Crea una nueva clave API para un logger. Las claves API permiten acceso de gestión al logger.

Autenticación

Requiere credenciales de gestión:

  • Api-Key — Tu clave API
  • Api-Secret — Tu secreto de API

Parámetros de Ruta

Parámetro Descripción
id El identificador único del logger

Cuerpo de la Solicitud

Campo Tipo Requerido Descripción
name string sí Una etiqueta para identificar esta clave API
1{
2  "name": "clave-ci-cd"
3}

Solicitud

curl -X POST "https://api.hola.cloud/v1/loggers/logger_xyz789/apiKeys" \
  -H "Api-Key: LOGGER_API_KEY" \
  -H "Api-Secret: LOGGER_API_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "clave-ci-cd"
  }'
POST /v1/loggers/logger_xyz789/apiKeys HTTP/1.1
Host: api.hola.cloud
Api-Key: LOGGER_API_KEY
Api-Secret: LOGGER_API_SECRET
Content-Type: application/json

{
    "name": "clave-ci-cd"
  }
// Go 1.21+, standard library only. Save as main.go and run: go run main.go
package main

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

func main() {
	payload := map[string]any{"name": "clave-ci-cd"}
	bodyBytes, err := json.Marshal(payload)
	if err != nil {
		panic(err)
	}
	body := string(bodyBytes)

	req, err := http.NewRequest("POST", "https://api.hola.cloud/v1/loggers/logger_xyz789/apiKeys", strings.NewReader(body))
	if err != nil {
		panic(err)
	}
	req.Header.Set("Api-Key", "LOGGER_API_KEY")
	req.Header.Set("Api-Secret", "LOGGER_API_SECRET")
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(resp.Status)
	fmt.Println(string(responseBody))
}
<?php
// PHP 8+ with the curl extension. Save as example.php and run: php example.php

$payload = ['name' => 'clave-ci-cd'];
$body = json_encode($payload);

$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.hola.cloud/v1/loggers/logger_xyz789/apiKeys',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_HTTPHEADER => [
        'Api-Key: LOGGER_API_KEY',
        'Api-Secret: LOGGER_API_SECRET',
        'Content-Type: application/json',
    ],
]);

$response = curl_exec($ch);
if ($response === false) {
    throw new Exception(curl_error($ch));
}
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), "\n", $response, "\n";
curl_close($ch);
# Python 3.8+. Install: pip install requests. Save as example.py and run: python example.py
import requests

headers = {
    "Api-Key": "LOGGER_API_KEY",
    "Api-Secret": "LOGGER_API_SECRET",
    "Content-Type": "application/json",
}

payload = {"name": "clave-ci-cd"}

response = requests.request(
    "POST",
    "https://api.hola.cloud/v1/loggers/logger_xyz789/apiKeys",
    headers=headers,
    json=payload
)

print(response.status_code)
print(response.text)
// Node.js 18+. Save as example.mjs and run: node example.mjs
const payload = {"name": "clave-ci-cd"};

const response = await fetch("https://api.hola.cloud/v1/loggers/logger_xyz789/apiKeys", {
  method: "POST",
  headers: {
    "Api-Key": "LOGGER_API_KEY",
    "Api-Secret": "LOGGER_API_SECRET",
    "Content-Type": "application/json"
  },
  body: JSON.stringify(payload)
});

console.log(response.status);
console.log(await response.text());
const payload = {"name": "clave-ci-cd"};

const response = await fetch("https://api.hola.cloud/v1/loggers/logger_xyz789/apiKeys", {
  method: "POST",
  headers: {
    "Api-Key": "LOGGER_API_KEY",
    "Api-Secret": "LOGGER_API_SECRET",
    "Content-Type": "application/json"
  },
  body: JSON.stringify(payload)
});

console.log(response.status);
console.log(await response.text());
// Java 17+, standard library only. Save as Main.java and run: java Main.java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        var body = """
{
    "name": "clave-ci-cd"
  }
""";

        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.hola.cloud/v1/loggers/logger_xyz789/apiKeys"))
            .method("POST", HttpRequest.BodyPublishers.ofString(body))
            .header("Api-Key", "LOGGER_API_KEY")
            .header("Api-Secret", "LOGGER_API_SECRET")
            .header("Content-Type", "application/json")
            .build();

        var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode());
        System.out.println(response.body());
    }
}
curl -X POST "https://api.hola.cloud/v1/loggers/logger_xyz789/apiKeys" \
  -H "Api-Key: LOGGER_API_KEY" \
  -H "Api-Secret: LOGGER_API_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "clave-ci-cd"
}'
POST /v1/loggers/logger_xyz789/apiKeys HTTP/1.1
Host: api.hola.cloud
Api-Key: LOGGER_API_KEY
Api-Secret: LOGGER_API_SECRET
Content-Type: application/json

{
  "name": "clave-ci-cd"
}
// Go 1.21+, standard library only. Save as main.go and run: go run main.go
package main

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

func main() {
	payload := map[string]any{"name": "clave-ci-cd"}
	bodyBytes, err := json.Marshal(payload)
	if err != nil {
		panic(err)
	}
	body := string(bodyBytes)

	req, err := http.NewRequest("POST", "https://api.hola.cloud/v1/loggers/logger_xyz789/apiKeys", strings.NewReader(body))
	if err != nil {
		panic(err)
	}
	req.Header.Set("Api-Key", "LOGGER_API_KEY")
	req.Header.Set("Api-Secret", "LOGGER_API_SECRET")
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(resp.Status)
	fmt.Println(string(responseBody))
}
<?php
// PHP 8+ with the curl extension. Save as example.php and run: php example.php

$payload = ['name' => 'clave-ci-cd'];
$body = json_encode($payload);

$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.hola.cloud/v1/loggers/logger_xyz789/apiKeys',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_HTTPHEADER => [
        'Api-Key: LOGGER_API_KEY',
        'Api-Secret: LOGGER_API_SECRET',
        'Content-Type: application/json',
    ],
]);

$response = curl_exec($ch);
if ($response === false) {
    throw new Exception(curl_error($ch));
}
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), "\n", $response, "\n";
curl_close($ch);
# Python 3.8+. Install: pip install requests. Save as example.py and run: python example.py
import requests

headers = {
    "Api-Key": "LOGGER_API_KEY",
    "Api-Secret": "LOGGER_API_SECRET",
    "Content-Type": "application/json",
}

payload = {"name": "clave-ci-cd"}

response = requests.request(
    "POST",
    "https://api.hola.cloud/v1/loggers/logger_xyz789/apiKeys",
    headers=headers,
    json=payload
)

print(response.status_code)
print(response.text)
// Node.js 18+. Save as example.mjs and run: node example.mjs
const payload = {"name": "clave-ci-cd"};

const response = await fetch("https://api.hola.cloud/v1/loggers/logger_xyz789/apiKeys", {
  method: "POST",
  headers: {
    "Api-Key": "LOGGER_API_KEY",
    "Api-Secret": "LOGGER_API_SECRET",
    "Content-Type": "application/json"
  },
  body: JSON.stringify(payload)
});

console.log(response.status);
console.log(await response.text());
const payload = {"name": "clave-ci-cd"};

const response = await fetch("https://api.hola.cloud/v1/loggers/logger_xyz789/apiKeys", {
  method: "POST",
  headers: {
    "Api-Key": "LOGGER_API_KEY",
    "Api-Secret": "LOGGER_API_SECRET",
    "Content-Type": "application/json"
  },
  body: JSON.stringify(payload)
});

console.log(response.status);
console.log(await response.text());
// Java 17+, standard library only. Save as Main.java and run: java Main.java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        var body = """
{
  "name": "clave-ci-cd"
}
""";

        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.hola.cloud/v1/loggers/logger_xyz789/apiKeys"))
            .method("POST", HttpRequest.BodyPublishers.ofString(body))
            .header("Api-Key", "LOGGER_API_KEY")
            .header("Api-Secret", "LOGGER_API_SECRET")
            .header("Content-Type", "application/json")
            .build();

        var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode());
        System.out.println(response.body());
    }
}

Respuesta

1{
2  "id": "ak_123456",
3  "name": "clave-ci-cd",
4  "key": "lgs_api_key_value",
5  "created_at": "2025-06-20T15:00:00Z"
6}

Códigos de Error

Código Descripción
400 Falta el campo name o es inválido
401 Credenciales de API faltantes o inválidas
403 Las credenciales no tienen acceso a este logger
404 Logger no encontrado

Comentarios

Deja un comentario