Content:
- General connection diagram of the clinic
- What information about the clinic is not available without sending a payment notification
- Authentication
- API Methods
To access the data, you must send information about payments accepted from the clinic to Medflex. Based on this data, Medflex opens access to the clinic's data via the API for a paid period.
Important! Access to the clinic's data via the API is provided within 1 hour after the transfer of payment information.
There is no free trial period. To get access to the clinic's data for the duration of the pilot, provide information about the payment for the minimum amount (starting from 1,000 ₽).
What information about the clinic is not available without sending a payment notification 
- Getting a list of appointments - GET /appointments/appointments/
- Receiving an appointment by UUID - GET /appointments/appointments/{uuid}/
- Admission status update - PATCH /appointments/appointments/{uuid}/
- Getting webhooks about creating and changing techniques in MIS GET /appointments/webhooks/
General connection diagram of the clinic 
Follow these steps when connecting a new clinic:
- Wait for the clinic to enable integration with your service in your Personal Account at Medflex.
- Receive the application from the clinic, sign the contract and accept the payment.
- Request information about the clinic using the GET /appointments/lpus/all/ method
- Send the payment information to Medflex via the billing API (the POST/billing/payments/method).
- Check that the payment has been completed for the specified period and the clinic data is available using the GET /appointments/lpus/ method.
- After receiving the payment, Medflex will open access to the clinic's API for the specified period (date_start – date_end).
- After the paid period expires, access will be closed automatically. To extend it, send information about the new payment.
Authentication 
To work with the billing API, use your individual partner token, the same one that you use for the main Trigger Mailing API. You do not need to receive a new token.
API Methods 
Getting information about clinics 
Use the GET /appointments/lpus/all/ method to get a list of all clinics that can be integrated with your service.
The GET /appointments/lpus/ method returns information about clinics with the success status.
Branch availability statuses 
- disabled - clinics where integration via trigger mailings is disabled in the Medflex personal account.
- need_payment - clinics that have integration enabled in their Medflex personal account and payment information is expected.
- need_mis_settings - Medflex has received information about the payment, but it needs to be configured in the clinic's MIS.
- success - the integration is working correctly.
Transmitting payment information 
To send payment information, use the POST/billing/payments/ method every time you receive a payment from the clinic. The Medflex API will start transmitting clinic data to your service only after a successful method call.
Important! Do not transfer the currency at the current stage. The system implies rubles (RUB).
Getting a list of transferred payments 
Use the GET/billing/payments/ method to verify data or generate reports. It returns a page-by-page list of all payments that your service has previously transferred to Medflex.
Extending access to clinic data 
To extend access to the clinic's data after the expiration of the paid period, send information about the new payment via the `POST /billing/payments/` method with the current values `date_start` and `date_end`.
Important! Provide for an early extension in your logic.
After the `date_end` date, access to clinic data via the API will be automatically closed and data transmission will stop until information about a new payment is received.
For questions about tokens, access rights, and payments, please contact your personal Medflex manager.