Salt la conținut
Documentație

Caută în documentație

    English

    Alerte

    Citește și gestionează resursele din categoria alerte prin API‑ul BI.

    Pe această pagină

    Listează: alerte

    GET /reports/v1/alerts

    Parametri

    NumeÎnTipObligatoriuDescriere
    limit query integer Nuopțional Înregistrări pe pagină. Implicit 100 Interval 1 – 500
    cursor query string Nuopțional nextCursor opac din pagina precedentă; păstrează filtrele.

    Răspunsuri

    StareDescriereCorp
    200 Rezultatul cerut. AlertPage
    400 Cerere refuzată. Coduri: invalid_request. Error
    401 Cerere refuzată. Coduri: unauthorized. Error
    403 Cerere refuzată. Coduri: forbidden. Error
    404 Cerere refuzată. Coduri: record_not_found, credential_not_found. Error
    409 Cerere refuzată. Coduri: revision_conflict, operation_reused. Error
    422 Cerere refuzată. Coduri: query_invalid, result_invalid, source_unavailable, refresh_running, refresh_not_running, stale_refresh, run_not_completed, delivery_not_parked, row_not_found, company_forbidden, recipient_forbidden, embed_origin_forbidden, operation_invalid, filter_invalid. Error
    429 Cerere refuzată. Coduri: rate_limited. Error
    503 Cerere refuzată. Coduri: unavailable. Error

    Cerere

    curl

    curl "$RDC_BASE_URL/reports/v1/alerts?limit=20" \
      -H "Authorization: Bearer $RDC_TOKEN"

    JavaScript

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

    Python

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

    PHP

    <?php
    
    $curl = curl_init(getenv('RDC_BASE_URL') . '/reports/v1/alerts?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#

    using System.Net.Http.Headers;
    
    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/reports/v1/alerts?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": [
        {
          "id": "revenue-below-target",
          "revision": 1,
          "metricId": "net-revenue",
          "operator": "below",
          "threshold": "190000.00",
          "currency": "RON",
          "questionId": "revenue-by-product",
          "enabled": true
        }
      ],
      "nextCursor": null
    }

    Configurează alerta

    POST /reports/v1/alerts

    Aplică modificarea o singură dată. Verifică operația înainte să citești rezultatul. Refolosirea operationId cu alt corp returnează operation_reused.

    Corpul cererii

    CâmpTipObligatoriuDescriere
    operationId string (uuid) Daobligatoriu Un UUID ales de apelant; refolosește‑l numai cu o cerere identică.
    expectedRevision integer Daobligatoriu Revizia citită înaintea modificării; zero pentru o resursă nouă.
    id string Daobligatoriu Identificator stabil al resursei.
    questionId string Daobligatoriu Identificator stabil al resursei.
    metricId string Daobligatoriu Identificator stabil al resursei.
    operator string Daobligatoriu Comparație aplicată după o execuție reușită. Una dintre below, above
    threshold string Daobligatoriu Sumă în RON, ca șir zecimal.
    currency string Daobligatoriu Moneda indicatorului. Una dintre RON
    enabled boolean Daobligatoriu Dacă această setare este activată.

    Răspunsuri

    StareDescriereCorp
    202 Acceptată pentru prelucrare; citește rezultatul operației. OperationResult
    400 Cerere refuzată. Coduri: invalid_request. Error
    401 Cerere refuzată. Coduri: unauthorized. Error
    403 Cerere refuzată. Coduri: forbidden. Error
    404 Cerere refuzată. Coduri: record_not_found, credential_not_found. Error
    409 Cerere refuzată. Coduri: revision_conflict, operation_reused. Error
    422 Cerere refuzată. Coduri: query_invalid, result_invalid, source_unavailable, refresh_running, refresh_not_running, stale_refresh, run_not_completed, delivery_not_parked, row_not_found, company_forbidden, recipient_forbidden, embed_origin_forbidden, operation_invalid, filter_invalid. Error
    429 Cerere refuzată. Coduri: rate_limited. Error
    503 Cerere refuzată. Coduri: unavailable. Error

    Cerere

    curl

    curl -X POST "$RDC_BASE_URL/reports/v1/alerts" \
      -H "Authorization: Bearer $RDC_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
      "operationId": "41800000-0000-4000-8000-000000000132",
      "expectedRevision": 0,
      "id": "revenue-below-target",
      "metricId": "net-revenue",
      "operator": "below",
      "threshold": "190000.00",
      "currency": "RON",
      "questionId": "revenue-by-product",
      "enabled": true
    }'

    JavaScript

    const response = await fetch(`${process.env.RDC_BASE_URL}/reports/v1/alerts`, {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.RDC_TOKEN}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        "operationId": "41800000-0000-4000-8000-000000000132",
        "expectedRevision": 0,
        "id": "revenue-below-target",
        "metricId": "net-revenue",
        "operator": "below",
        "threshold": "190000.00",
        "currency": "RON",
        "questionId": "revenue-by-product",
        "enabled": true
      }),
    });
    const result = await response.json();

    Python

    import os
    import requests
    
    response = requests.request(
        'POST',
        f'{os.environ["RDC_BASE_URL"]}/reports/v1/alerts',
        headers={
            'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
        },
        json={
            'operationId': '41800000-0000-4000-8000-000000000132',
            'expectedRevision': 0,
            'id': 'revenue-below-target',
            'metricId': 'net-revenue',
            'operator': 'below',
            'threshold': '190000.00',
            'currency': 'RON',
            'questionId': 'revenue-by-product',
            'enabled': True,
        },
    )
    result = response.json()

    PHP

    <?php
    
    $body = <<<'JSON'
    {
      "operationId": "41800000-0000-4000-8000-000000000132",
      "expectedRevision": 0,
      "id": "revenue-below-target",
      "metricId": "net-revenue",
      "operator": "below",
      "threshold": "190000.00",
      "currency": "RON",
      "questionId": "revenue-by-product",
      "enabled": true
    }
    JSON;
    
    $curl = curl_init(getenv('RDC_BASE_URL') . '/reports/v1/alerts');
    curl_setopt_array($curl, [
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            'Authorization: Bearer ' . getenv('RDC_TOKEN'),
            'Content-Type: application/json',
        ],
        CURLOPT_POSTFIELDS => $body,
    ]);
    $result = json_decode(curl_exec($curl), true);
    curl_close($curl);

    C#

    using System.Net.Http.Headers;
    
    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/reports/v1/alerts");
    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
    request.Content = new StringContent("""
    {
      "operationId": "41800000-0000-4000-8000-000000000132",
      "expectedRevision": 0,
      "id": "revenue-below-target",
      "metricId": "net-revenue",
      "operator": "below",
      "threshold": "190000.00",
      "currency": "RON",
      "questionId": "revenue-by-product",
      "enabled": true
    }
    """, System.Text.Encoding.UTF8, "application/json");
    var response = await client.SendAsync(request);
    var result = await response.Content.ReadAsStringAsync();

    Răspuns 202

    JSON

    {
      "operationId": "41800000-0000-4000-8000-000000000132",
      "status": "accepted",
      "aggregateRevision": 1
    }

    Citește înregistrarea

    GET /reports/v1/alerts/{id}

    Parametri

    NumeÎnTipObligatoriuDescriere
    id path string Daobligatoriu Identificatorul resursei.

    Răspunsuri

    StareDescriereCorp
    200 Rezultatul cerut. Alert
    400 Cerere refuzată. Coduri: invalid_request. Error
    401 Cerere refuzată. Coduri: unauthorized. Error
    403 Cerere refuzată. Coduri: forbidden. Error
    404 Cerere refuzată. Coduri: record_not_found, credential_not_found. Error
    409 Cerere refuzată. Coduri: revision_conflict, operation_reused. Error
    422 Cerere refuzată. Coduri: query_invalid, result_invalid, source_unavailable, refresh_running, refresh_not_running, stale_refresh, run_not_completed, delivery_not_parked, row_not_found, company_forbidden, recipient_forbidden, embed_origin_forbidden, operation_invalid, filter_invalid. Error
    429 Cerere refuzată. Coduri: rate_limited. Error
    503 Cerere refuzată. Coduri: unavailable. Error

    Cerere

    curl

    curl "$RDC_BASE_URL/reports/v1/alerts/revenue-below-target" \
      -H "Authorization: Bearer $RDC_TOKEN"

    JavaScript

    const response = await fetch(`${process.env.RDC_BASE_URL}/reports/v1/alerts/revenue-below-target`, {
      method: 'GET',
      headers: {
        Authorization: `Bearer ${process.env.RDC_TOKEN}`,
      },
    });
    const result = await response.json();

    Python

    import os
    import requests
    
    response = requests.request(
        'GET',
        f'{os.environ["RDC_BASE_URL"]}/reports/v1/alerts/revenue-below-target',
        headers={
            'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
        },
    )
    result = response.json()

    PHP

    <?php
    
    $curl = curl_init(getenv('RDC_BASE_URL') . '/reports/v1/alerts/revenue-below-target');
    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#

    using System.Net.Http.Headers;
    
    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/reports/v1/alerts/revenue-below-target");
    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

    {
      "id": "revenue-below-target",
      "revision": 1,
      "metricId": "net-revenue",
      "operator": "below",
      "threshold": "190000.00",
      "currency": "RON",
      "questionId": "revenue-by-product",
      "enabled": true
    }