Facta API

Direct HTTP: Java

No Facta library required

Call the public Supabase function URL directly. Keep API keys and signing keys on your server.

Prerequisite

JDK java.net.http

Example

import java.net.URI;
import java.net.http.*;
public final class Emitir {
  public static void main(String[] args) throws Exception {
    var body = "{\"tipoDte\":\"01\",\"items\":[{\"descripcion\":\"Servicio\",\"cantidad\":1,\"precioUni\":10.0}]}";
    var request = HttpRequest.newBuilder(URI.create(System.getenv("FACTA_API_BASE_URL") + "/v1/dte")).header("Content-Type", "application/json").header("X-Facta-Key", System.getenv("FACTA_API_KEY")).header("X-Facta-Sign-Key", System.getenv("FACTA_SIGN_KEY")).header("Idempotency-Key", "order-123").POST(HttpRequest.BodyPublishers.ofString(body)).build();
    System.out.println(HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()).body());
  }
}

See the HTTP reference for headers, responses and recovery rules.