Recepción y aprobación comercial
Gravitas publica para cada empresa los servicios de recepción que exige la DGII: recibe los e-CF de tus proveedores, valida firma y estructura, y devuelve al instante el acuse de recibo firmado (ARECF).
Leer los recibidos
Sección titulada «Leer los recibidos»# Listar los e-CF recibidos de proveedores de la empresa 101000001.curl -s "https://tuempresa.gravitastec.com/api/v1/companies/0192f1a0-0000-7000-8000-000000000001/received-documents" \ -H "Authorization: Bearer $TOKEN"// Listar los e-CF recibidos de proveedores de la empresa 101000001.using System.Net.Http.Headers;using System.Net.Http.Json;using System.Text.Json;
var api = new HttpClient { BaseAddress = new Uri("https://tuempresa.gravitastec.com/api/v1/") };var form = new FormUrlEncodedContent(new Dictionary<string, string>{ ["grant_type"] = "client_credentials", ["client_id"] = "YOUR_CLIENT_ID", ["client_secret"] = Environment.GetEnvironmentVariable("GRAVITAS_CLIENT_SECRET") ?? "YOUR_CLIENT_SECRET",});var tokenResponse = await api.PostAsync("oauth/token", form);tokenResponse.EnsureSuccessStatusCode();var token = JsonDocument.Parse(await tokenResponse.Content.ReadAsStringAsync()).RootElement.GetProperty("access_token").GetString();api.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var received = await api.GetFromJsonAsync<JsonElement>("companies/0192f1a0-0000-7000-8000-000000000001/received-documents");Console.WriteLine(received);// Listar los e-CF recibidos de proveedores de la empresa 101000001. Node 20+.const baseUrl = 'https://tuempresa.gravitastec.com/api/v1';const tokenResponse = await fetch(`${baseUrl}/oauth/token`, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ grant_type: 'client_credentials', client_id: 'YOUR_CLIENT_ID', client_secret: process.env.GRAVITAS_CLIENT_SECRET ?? 'YOUR_CLIENT_SECRET', }),});const { access_token: token } = await tokenResponse.json();const auth = { Authorization: `Bearer ${token}` };
const received = await (await fetch(`${baseUrl}/companies/0192f1a0-0000-7000-8000-000000000001/received-documents`, { headers: auth })).json();console.log(received);Marca cada documento como integrado con POST /received-documents/{receivedId}/integrated cuando tu ERP lo
haya registrado. El XML original está en GET /received-documents/{receivedId}/xml.
Aprobar o rechazar
Sección titulada «Aprobar o rechazar»# Aprobar comercialmente un e-CF recibido (envía el ACECF al proveedor y a la DGII).curl -s -X POST "https://tuempresa.gravitastec.com/api/v1/received-documents/$RECEIVED_ID/approval" \ -H "Authorization: Bearer $TOKEN" \ -H "Idempotency-Key: aprobacion-0001" \ -H "Content-Type: application/json" \ -d '{ "decision": "accepted" }'// Aprobar comercialmente un e-CF recibido.using System.Net.Http.Headers;using System.Net.Http.Json;using System.Text.Json;
var api = new HttpClient { BaseAddress = new Uri("https://tuempresa.gravitastec.com/api/v1/") };var form = new FormUrlEncodedContent(new Dictionary<string, string>{ ["grant_type"] = "client_credentials", ["client_id"] = "YOUR_CLIENT_ID", ["client_secret"] = Environment.GetEnvironmentVariable("GRAVITAS_CLIENT_SECRET") ?? "YOUR_CLIENT_SECRET",});var tokenResponse = await api.PostAsync("oauth/token", form);tokenResponse.EnsureSuccessStatusCode();var token = JsonDocument.Parse(await tokenResponse.Content.ReadAsStringAsync()).RootElement.GetProperty("access_token").GetString();api.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var receivedId = args[0];var request = new HttpRequestMessage(HttpMethod.Post, $"received-documents/{receivedId}/approval"){ Content = JsonContent.Create(new { decision = "accepted" }),};request.Headers.Add("Idempotency-Key", "aprobacion-0001");var response = await api.SendAsync(request);Console.WriteLine((int)response.StatusCode);// Aprobar comercialmente un e-CF recibido. Node 20+.const baseUrl = 'https://tuempresa.gravitastec.com/api/v1';const tokenResponse = await fetch(`${baseUrl}/oauth/token`, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ grant_type: 'client_credentials', client_id: 'YOUR_CLIENT_ID', client_secret: process.env.GRAVITAS_CLIENT_SECRET ?? 'YOUR_CLIENT_SECRET', }),});const { access_token: token } = await tokenResponse.json();const auth = { Authorization: `Bearer ${token}` };
const receivedId = process.argv[2];const response = await fetch(`${baseUrl}/received-documents/${receivedId}/approval`, { method: 'POST', headers: { ...auth, 'Content-Type': 'application/json', 'Idempotency-Key': 'aprobacion-0001' }, body: JSON.stringify({ decision: 'accepted' }),});console.log(response.status);La decisión genera la aprobación comercial (ACECF), que Gravitas envía al proveedor y una copia a la DGII. Antes de aprobar, verificamos en la DGII que el e-CF fue aceptado y que el proveedor está activo.