---
title: "Autentificare | Documentație | Accounting by R&D Copilot"
description: "Obține datele de acces, cere un token și apelează cu el API-ul Accounting."
canonical: "https://accounting.rdcopilot.com/ro/docs/get-started/authentication/"
language: ro
updated: 2026-11-22
---

# Autentificare

Obține datele de acces, cere un token și apelează cu el API-ul Accounting.

Datele de acces ale clientului API, adresa de bază și o companie de test se emit odată cu contul. Conturile sunt deschise de echipa noastră: cere unul prin formularul de contact și îl configurăm împreună.

[Cere un cont](https://rdcopilot.com/ro/contact/?product=accounting&topic=api-access)

## Cere un token

API-ul folosește OAuth 2.0 cu fluxul client credentials. Clientul tău cere serviciului de autentificare un token pentru scope-ul `accounting.access` și îl trimite ca token de tip bearer la fiecare cerere.

Cererea de token

```bash
curl -X POST "$RDC_TOKEN_URL" \
  -d "grant_type=client_credentials" \
  -d "client_id=$RDC_CLIENT_ID" \
  -d "client_secret=$RDC_CLIENT_SECRET" \
  -d "scope=accounting.access"
```

Răspunsul conține aceste câmpuri.

| Câmp | Descriere |
| --- | --- |
| `access_token` | Tokenul. Trimite-l ca `Authorization: Bearer $RDC_TOKEN`. |
| `token_type` | Întotdeauna `Bearer`. |
| `expires_in` | Secundele rămase până la expirarea tokenului. Reutilizează tokenul până atunci și cere unul nou înainte să expire. Nu cere un token la fiecare cerere. |

## Apelează API-ul

Fiecare cerere include tokenul. Exemplul listează înregistrări și arată antetul în fiecare limbaj.

curl

```bash
curl "$RDC_BASE_URL/accounting/v1/posting-requests?limit=20" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/accounting/v1/posting-requests?limit=20`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
  },
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'GET',
    f'{os.environ["RDC_BASE_URL"]}/accounting/v1/posting-requests?limit=20',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/accounting/v1/posting-requests?limit=20');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
    ],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/accounting/v1/posting-requests?limit=20");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

Răspuns 200

```json
{
  "items": [
    {
      "postingRequestId": "52330eaa-1840-49f8-895a-81219a047cf3",
      "status": "accepted",
      "sourceDocumentId": "ba5fba82-7611-4773-b950-793839664863",
      "sourceDocumentType": "supplier_invoice",
      "sourceRevision": 2,
      "effectiveDate": "2026-10-22",
      "mappingPolicyVersion": "ro-2026.1",
      "journalEntryId": null,
      "rejection": null,
      "aggregateRevision": 1
    },
    {
      "postingRequestId": "b7007a22-a9ea-4fcb-b535-e0570cdd1f2e",
      "status": "posted",
      "sourceDocumentId": "58572830-d5ca-43ff-bd1d-d7ca383d5c65",
      "sourceDocumentType": "supplier_invoice",
      "sourceRevision": 2,
      "effectiveDate": "2026-10-21",
      "mappingPolicyVersion": "ro-2026.1",
      "journalEntryId": "d75fc649-ee06-4dfb-ab83-94b5f1209aa8",
      "rejection": null,
      "aggregateRevision": 2
    },
    {
      "postingRequestId": "eefbc55a-4da9-42d9-8c56-9764421e1fff",
      "status": "rejected",
      "sourceDocumentId": "3795da47-15fc-4086-a5f5-f33e0bcd2efe",
      "sourceDocumentType": "supplier_invoice",
      "sourceRevision": 2,
      "effectiveDate": "2026-10-29",
      "mappingPolicyVersion": "ro-2026.1",
      "journalEntryId": null,
      "rejection": {
        "code": "unbalanced",
        "message": "Debit and credit of the facts differ by 0.01. Nothing was posted."
      },
      "aggregateRevision": 2
    }
  ],
  "nextCursor": null
}
```

## Cereri refuzate

| Cod de stare | Cod | Cauză | Ce faci |
| --- | --- | --- | --- |
| `401` | `unauthorized` | Niciun token sau un token nevalid ori expirat. | Cere un token nou, apoi repetă cererea. |
| `403` | `forbidden` | Un token valid fără scope-ul `accounting.access` sau o cerere pentru date din afara contului tău. | Nu o repeta. Verifică scope-ul și societatea. |

Păstrează secretul clientului pe un server pe care îl controlezi. Nu îl pune într-o pagină web sau într-o aplicație mobilă.

Construiește mai întâi pe compania de test. Citește [Test și producție](https://accounting.rdcopilot.com/ro/docs/get-started/sandbox-and-live/).

Regula completă: [Ghidul dezvoltatorului](https://rdcopilot.com/ro/docs/authentication/)
