For partners

Roaming partner documentation

Let your drivers charge at MGLBG Charge charge points with your own app, through one OCPI 2.2.1 connection to the MagicLine Roaming Hub.

Set it up with your AI coding agent

Give this file to Claude Code, Cursor or another AI coding agent. It walks the agent through the whole integration in your own codebase, step by step, and tells it what to ask you first.

Download the AI setup guideMarkdown file, in English

Overview

Introduction

Your customers can charge at MGLBG Charge charge points in Bulgaria and start the charge from your own app. You connect once to the MagicLine Roaming Hub over OCPI 2.2.1. The hub gives you our station data and your prices, relays start and stop commands, reports sessions and charge detail records, and produces a monthly settlement statement.

This documentation is for e-mobility service providers (eMSPs) that want to give their drivers access to our network.

TopicWhat it means for you
NetworkMGLBG Charge charge points in Bulgaria, published under the OCPI party BG*MGL
ProtocolOCPI 2.2.1
Your roleeMSP: your customers charge on our charge points
How drivers startFrom your app (remote start and stop)
Who pays whomYou bill your driver; we invoice you monthly from the settlement statement
AvailabilityIntegration testing first; production access per partner after testing and a signed agreement

How a charge works

A driver finds our charge point in your app, starts and stops the charge there, and you receive the final record with your price within seconds of the end. Your platform only talks to the hub; the hub drives the charge point.

  1. 1

    Your platformHubyour polling interval

    Pull locations and tariffs

    Only charge points enabled for your company are returned, each with your partner-specific tariff.

  2. 2

    Your platformHub

    Driver taps start: START_SESSION

    The hub answers at once; the final result follows at your response_url.

  3. 3

    HubYour platformanswer within 10 s

    Is this token allowed to charge?

    Real-time authorization on your Tokens endpoint. Any answer other than ALLOWED stops the start.

  4. 4

    HubCharge pointup to 2 min

    Start charging

    If the cable is not plugged in yet, the charge point waits for it.

  5. 5

    HubYour platform

    Command result ACCEPTED, session ACTIVE

    Status changes arrive at once; energy and the amount at your price about once a minute.

  6. 6

    Your platformHub

    Driver taps stop: STOP_SESSION

    Or the driver ends the charge at the vehicle or the charge point.

  7. 7

    HubYour platformseconds after the end

    Charge detail record (CDR) with your price

    One CDR per completed session with energy. A session that never started or delivered no energy has none.

  8. 8

    HubYour platformmonthly

    Monthly settlement statement and invoice

    Built from the CDRs of the month.

Get started

Onboarding runs from a signed agreement through a test connection to production. Connection details are shared only privately.

  1. Contact and agreement. We agree your price rule, payment terms and data processing terms.
  2. Company details. Legal name, VAT number, address, bank details, technical and commercial contacts, your OCPI party ID and role.
  3. Test connection. We register your company in the test environment and send you a one-time registration token and our versions address through an agreed secure channel.
  4. End-to-end tests. Location and tariff pulls, start and stop, real-time authorization, sessions and CDRs.
  5. Production. Registered separately, with a new one-time token. We then enable our charge points for your company.
  6. Settlement. Monthly statements start with your first production charge.

Integration

Connection and authentication

Registration follows the OCPI 2.2.1 Credentials module. You call our credentials endpoint once with the one-time token; the hub reads your versions endpoint and the two sides exchange new tokens. From then on every call, in both directions, carries the token of the receiving side.

Every request
GET https://<hub address, shared at onboarding>/ocpi/2.2.1/locations?limit=50
Authorization: Token <base64 of the token>
X-Request-ID: 7b0c3f0e-5d1a-4c55-9a7e-2f3b1c9d8e01
X-Correlation-ID: 7b0c3f0e-5d1a-4c55-9a7e-2f3b1c9d8e01
OCPI-from-country-code: BG
OCPI-from-party-id: ABC
  • HTTPS only, with a certificate from a publicly trusted authority.
  • The token is sent Base64-encoded, as OCPI 2.2.1 specifies: Authorization: Token <base64>.
  • Send X-Request-ID and X-Correlation-ID on every request, and the OCPI-from-* headers with your own party.
  • Field names and formats follow the OCPI 2.2.1 specification; all timestamps are UTC.

Modules

OCPI moduleHub's role toward youYour platform
Versions, CredentialsSender and receiverRegisters once; tokens are then exchanged automatically
LocationsSenderPulls locations
TariffsSenderPulls your partner-specific tariffs
CommandsReceiverSends START_SESSION and STOP_SESSION
TokensCalls your SenderAnswers real-time authorization within 10 seconds
SessionsSender, pushes to your ReceiverReceiver optional; otherwise pull
CDRsSender, pushes to your ReceiverReceiver optional; otherwise pull

Locations

Pull our charge points with date_from and date_to (on last_updated) and offset/limit paging; follow the Link header for the next page. A single location, EVSE or connector can be read by its path. Changes reach the hub within about a minute.

Request
GET https://<hub address, shared at onboarding>/ocpi/2.2.1/locations?date_from=2026-11-18T00:00:00Z&offset=0&limit=50
Response (shortened)
{
  "data": [
    {
      "country_code": "BG",
      "party_id": "MGL",
      "id": "0195a3b4-0000-7000-8000-000000000001",
      "publish": true,
      "name": "Example station",
      "address": "1 Example Blvd",
      "city": "Sofia",
      "country": "BGR",
      "coordinates": { "latitude": "42.697700", "longitude": "23.321900" },
      "time_zone": "Europe/Sofia",
      "evses": [
        {
          "uid": "0195a3b4-0000-7000-8000-000000000101",
          "evse_id": "BG*MGL*E000001*1",
          "status": "AVAILABLE",
          "capabilities": ["REMOTE_START_STOP_CAPABLE"],
          "connectors": [
            {
              "id": "1",
              "standard": "IEC_62196_T2",
              "format": "SOCKET",
              "power_type": "AC_3_PHASE",
              "max_voltage": 230,
              "max_amperage": 32,
              "max_electric_power": 22000,
              "tariff_ids": ["<your tariff id>"],
              "last_updated": "2026-11-18T09:00:00Z"
            }
          ],
          "last_updated": "2026-11-18T09:00:00Z"
        }
      ],
      "last_updated": "2026-11-18T09:00:00Z"
    }
  ],
  "status_code": 1000,
  "status_message": "Success",
  "timestamp": "2026-11-18T09:00:05Z"
}

Use the EVSE uid to start

START_SESSION names the location id and the EVSE uid. The evse_id is the readable ID to show to drivers.

Tariffs

The tariffs you pull are yours alone: they carry the price agreed for your company. Prices are per kWh, excluding VAT, with the VAT rate. Each connector points to its tariff through tariff_ids.

One tariff from GET /tariffs
{
  "country_code": "BG",
  "party_id": "MGL",
  "id": "<your tariff id>",
  "currency": "EUR",
  "elements": [
    { "price_components": [ { "type": "ENERGY", "price": 0.4167, "vat": 20.0, "step_size": 1 } ] }
  ],
  "last_updated": "2026-11-18T09:00:00Z"
}

Commands: start and stop

Send START_SESSION with the driver's token and the EVSE. The hub answers at once with ACCEPTED and a timeout; the outcome follows as a CommandResult posted to your response_url within that timeout.

Request
POST https://<hub address, shared at onboarding>/ocpi/2.2.1/commands/START_SESSION

{
  "response_url": "https://<your platform>/ocpi/2.2.1/commands/START_SESSION/8f1d2c3b",
  "token": {
    "country_code": "BG",
    "party_id": "ABC",
    "uid": "TOKEN-123",
    "type": "APP_USER",
    "contract_id": "BG-ABC-C00000001",
    "issuer": "Your company",
    "valid": true,
    "whitelist": "NEVER",
    "last_updated": "2026-11-18T09:05:00Z"
  },
  "location_id": "0195a3b4-0000-7000-8000-000000000001",
  "evse_uid": "0195a3b4-0000-7000-8000-000000000101"
}
Immediate response
{ "data": { "result": "ACCEPTED", "timeout": 230 }, "status_code": 1000, "status_message": "Success", "timestamp": "2026-11-18T09:05:01Z" }
CommandResult posted to your response_url
{ "result": "ACCEPTED" }
ValueMeaning
ACCEPTEDCharging started (or, for a stop, the charge ended)
REJECTEDNot allowed: your authorization answer, or the charge point refused
EVSE_OCCUPIEDThe connector is in use
EVSE_INOPERATIVEThe charge point is offline, closed or faulted
TIMEOUTThe cable was not plugged in, or the charge point did not respond in time
FAILEDAny other failure

To stop, send STOP_SESSION with the session_id of the Session object. A stop for a session that is not yours is answered with UNKNOWN_SESSION; for a session that has already ended, the result at your response_url is FAILED.

Request
POST https://<hub address, shared at onboarding>/ocpi/2.2.1/commands/STOP_SESSION

{ "response_url": "https://<your platform>/ocpi/2.2.1/commands/STOP_SESSION/9a2e4d5c", "session_id": "0195b000-0000-7000-8000-000000000001" }

Real-time authorization

Before every start the hub asks your Tokens endpoint whether the token may charge at that location. Only ALLOWED lets the start go ahead; BLOCKED, EXPIRED, NO_CREDIT and NOT_ALLOWED stop it.

The hub calls your platform
POST https://<your platform>/ocpi/2.2.1/tokens/TOKEN-123/authorize?type=APP_USER

{ "location_id": "0195a3b4-0000-7000-8000-000000000001", "evse_uids": ["0195a3b4-0000-7000-8000-000000000101"] }
Your response
{ "data": { "allowed": "ALLOWED", "token": { "country_code": "BG", "party_id": "ABC", "uid": "TOKEN-123", "type": "APP_USER", "contract_id": "BG-ABC-C00000001", "issuer": "Your company", "valid": true, "whitelist": "NEVER", "last_updated": "2026-11-18T09:05:00Z" } }, "status_code": 1000, "timestamp": "2026-11-18T09:05:01Z" }

Answer within 10 seconds

If your endpoint does not answer within 10 seconds or cannot be reached, the charge still starts so the driver is not left waiting at the charge point. Such sessions are flagged and listed separately in the monthly statement. Keep this endpoint available.

Sessions

While a charge runs you receive the Session object with status, energy and total_cost at your price. If you expose a Sessions receiver, the hub pushes the full object with PUT; otherwise pull GET /sessions with the same paging as Locations. Status changes arrive at once, energy about once a minute.

Pushed to your Sessions receiver
PUT https://<your platform>/ocpi/2.2.1/sessions/BG/MGL/0195b000-0000-7000-8000-000000000001

{
  "country_code": "BG",
  "party_id": "MGL",
  "id": "0195b000-0000-7000-8000-000000000001",
  "start_date_time": "2026-11-18T09:05:20Z",
  "kwh": 4.32,
  "cdr_token": { "country_code": "BG", "party_id": "ABC", "uid": "TOKEN-123", "type": "APP_USER", "contract_id": "BG-ABC-C00000001" },
  "auth_method": "COMMAND",
  "location_id": "0195a3b4-0000-7000-8000-000000000001",
  "evse_uid": "0195a3b4-0000-7000-8000-000000000101",
  "connector_id": "1",
  "currency": "EUR",
  "total_cost": { "excl_vat": 1.80, "incl_vat": 2.16 },
  "status": "ACTIVE",
  "last_updated": "2026-11-18T09:07:00Z"
}

Statuses: PENDING (waiting for the cable or starting), ACTIVE, COMPLETED, and INVALID for a start that never happened.

Charge detail records

Every completed session with energy produces one CDR, a few seconds after the end. Its total_cost is your price. A CDR is never changed. If you expose a CDRs receiver, the hub posts it there and retries for 24 hours; you can always pull GET /cdrs, where date_from and date_to refer to when the hub received the record.

Posted to your CDRs receiver (shortened)
POST https://<your platform>/ocpi/2.2.1/cdrs

{
  "country_code": "BG",
  "party_id": "MGL",
  "id": "0195b000-0000-7000-8000-000000000001",
  "start_date_time": "2026-11-18T09:05:20Z",
  "end_date_time": "2026-11-18T09:35:20Z",
  "session_id": "0195b000-0000-7000-8000-000000000001",
  "cdr_token": { "country_code": "BG", "party_id": "ABC", "uid": "TOKEN-123", "type": "APP_USER", "contract_id": "BG-ABC-C00000001" },
  "auth_method": "COMMAND",
  "cdr_location": {
    "id": "0195a3b4-0000-7000-8000-000000000001",
    "name": "Example station",
    "address": "1 Example Blvd",
    "city": "Sofia",
    "country": "BGR",
    "coordinates": { "latitude": "42.697700", "longitude": "23.321900" },
    "evse_uid": "0195a3b4-0000-7000-8000-000000000101",
    "evse_id": "BG*MGL*E000001*1",
    "connector_id": "1",
    "connector_standard": "IEC_62196_T2",
    "connector_format": "SOCKET",
    "connector_power_type": "AC_3_PHASE"
  },
  "currency": "EUR",
  "charging_periods": [ { "start_date_time": "2026-11-18T09:05:20Z", "dimensions": [ { "type": "ENERGY", "volume": 7.5 } ] } ],
  "total_cost": { "excl_vat": 3.13, "incl_vat": 3.75 },
  "total_energy": 7.5,
  "total_time": 0.5,
  "last_updated": "2026-11-18T09:35:25Z"
}

Status codes

Every response uses the OCPI envelope. These are the status codes the hub returns.

status_codeHTTPMeaning
1000200Success
2000401Missing or invalid token
2000403Not allowed for your company, or your company is not active
2001400Invalid or missing parameters
2003404Unknown location
3001400Registration could not use your API (your versions endpoint was not reachable)
3002400No common OCPI version (2.2.1 is required)
3003400Your 2.2.1 endpoints do not include credentials
3000500Server error; retry later

Business

Pricing and settlement

You pay the price agreed for your company, once a month, from a statement built on the CDRs.

TopicHow it works
Price ruleAgreed per partner: our standard tariff, a percentage discount on it, or a fixed price per kWh (AC and DC can differ)
Price stabilityThe price is fixed when the session starts; a later tariff change does not affect a running charge
Your driver's priceYour decision; we do not charge your drivers
Settlement periodCalendar month in the charge point's local time (Europe/Sofia), by session end
StatementNumber of CDRs, kWh and amounts excluding and including VAT, as a CSV file
Late recordsA CDR that arrives after its month has ended is added to its own month and marked as late
Invoice and paymentWe invoice you from the statement; payment terms are set in the agreement

Reference

Security and data protection

  • Encrypted transport. All traffic runs over HTTPS; unencrypted connections are refused.
  • Credentials. The registration token works once and is replaced during registration. Credentials are stored encrypted, never written to logs, and can be revoked and reissued at any time.
  • Separate environments. Test and production are fully separate, each with its own credentials.
  • Data separation. You see only the charge points enabled for your company and only your own sessions and CDRs. Commands are accepted only for your own tokens and sessions.
  • Data minimisation. Records carry the token ID and contract ID, never names, e-mail addresses or phone numbers.
  • GDPR. Data processing terms are part of the agreement.
  • Reporting a vulnerability. Write to info@magiclineenergy.com and do not publish details before we have responded.

Current scope

FeatureStatus
Station data and partner-specific tariffsSupported
Remote start and stop from your app, real-time authorizationSupported
Sessions, CDRs, monthly settlement statementSupported
Start with an RFID card at the charge pointNot yet
Reservations, smart charging (charging profiles)Not offered
OCPI 2.3Not yet; 2.2.1 only

Contact

To start, write to info@magiclineenergy.com with your company name, country, OCPI party ID and the number of drivers you expect to bring.