### Get and Create Clients with /api/v1/clients Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Use GET to list clients with search and pagination, and POST to add new clients. Both require user authorization. ```bash # Получение списка клиентов с поиском curl -X GET "https://api.yclients.com/api/v1/clients/4564?page=1&count=20&search=Иван" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" ``` ```bash # Создание нового клиента curl -X POST "https://api.yclients.com/api/v1/clients/4564" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" \ -d '{ "name": "Василий", "surname": "Сонов", "phone": 79211234567, "email": "vasiliy@example.com", "sex_id": 1, "importance_id": 1, "discount": 10, "birth_date": "1990-05-15", "comment": "Постоянный клиент", "sms_check": 1, "sms_not": 0, "categories": [101, 102], "custom_fields": { "source": "website" } }' ``` -------------------------------- ### Get and Create Records with /api/v1/records Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Use GET to retrieve appointment records with filtering options, and POST to create new appointments as an administrator. Both require user authorization. ```bash # Получение записей с фильтром по дате curl -X GET "https://api.yclients.com/api/v1/records/4564?start_date=2024-06-01&end_date=2024-06-30&staff_id=924&page=1&count=50" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" ``` ```bash # Создание записи администратором curl -X POST "https://api.yclients.com/api/v1/records/4564" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" \ -d '{ "staff_id": 924, "services": [{ "id": 2838, "cost": 1500, "amount": 1 }], "client": { "phone": "79161502239", "name": "Иван Петров" }, "datetime": "2024-06-20T11:00:00+03:00", "seance_length": 3600, "comment": "Административная запись", "send_sms": true }' ``` -------------------------------- ### Get Company List with GET /api/v1/companies Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Retrieve a list of companies, with options to filter by group, country, and city. Setting `forBooking=1` includes the `next_slot` field for immediate booking availability. ```bash curl -X GET "https://api.yclients.com/api/v1/companies?country_id=1&city_id=1&forBooking=1&count=10&page=1" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN" ``` -------------------------------- ### Get Custom Fields Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Retrieves a list of custom fields configured for a company. Requires partner and user tokens. ```bash curl -X GET "https://api.yclients.com/api/v1/company/4564/custom_fields" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" ``` -------------------------------- ### Phone Validation Response Example Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Example of a successful response from the phone validation endpoint, indicating a valid number and its formatted representation. ```json # Ответ при валидном номере: # { "success": true, "data": { "valid": true, "formatted": "+7 (916) 150-22-39" }, "meta": [] } ``` -------------------------------- ### Get Visit Details Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Retrieves detailed information about a specific visit, including associated services, financial transactions, and payment status. Requires visit_id. ```bash curl -X GET "https://api.yclients.com/api/v1/visits/8262996" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" ``` -------------------------------- ### Get Z-Report Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Retrieves a summary Z-report for a company for a specified date, including statistics on clients, records, and payments. Requires partner and user tokens. ```bash curl -X GET "https://api.yclients.com/api/v1/salon/4564/z_report?date=2024-06-15" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" ``` -------------------------------- ### Get User Permissions Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Retrieves the full list of permissions for a specific user within a company. Requires company and user IDs. ```bash # Получение прав пользователя curl -X GET "https://api.yclients.com/api/v1/company/4564/users/123456/permissions" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" ``` -------------------------------- ### Book Check Error Response Example Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Example of an error response from the book_check endpoint, specifically for a conflict or unavailable time slot, indicated by an HTTP 422 status code. ```json # Ответ при занятом времени (book_check): # HTTP 422: { "success": false, "meta": { "error_code": 433, "id": 1 } } ``` -------------------------------- ### Authenticate User and Obtain User Token Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Use this method to get a user_token for authenticated API calls. Supports two-factor authentication, returning a 200 status for code entry and 201 upon successful authentication. ```bash curl -X POST "https://api.yclients.com/api/v1/auth" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN" \ -d '{ "login": "user@example.com", "password": "secretpassword" }' ``` ```json # Response upon successful authorization (HTTP 201): # { # "success": true, # "data": { # "id": 123456, # "login": "user@example.com", # "user_token": "abc123def456ghi789", # "name": "Иван Иванов" # }, # "meta": [] # } ``` ```bash # Step 2 (with 2FA enabled): sending confirmation code curl -X POST "https://api.yclients.com/api/v1/auth" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN" \ -d '{ "login": "user@example.com", "password": "secretpassword", "code": "123456" }' ``` -------------------------------- ### Get Services for Booking Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Retrieves a list of services available for booking, with an option to filter by a specific staff member. Essential for the online booking interface. ```bash curl -X GET "https://api.yclients.com/api/v1/book_services/4564?staff_id=924" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN" ``` -------------------------------- ### Get Client Loyalty Cards Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Retrieves loyalty cards associated with a specific client ID within a company. Requires partner and user tokens. ```bash curl -X GET "https://api.yclients.com/api/v1/loyalty/cards/4564/1121412" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" ``` -------------------------------- ### Get Staff for Booking Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Retrieves a list of staff members available for booking, optionally filtered by service IDs. Used for building the online booking interface. ```bash curl -X GET "https://api.yclients.com/api/v1/book_staff/4564?service_ids[]=2838" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN" ``` -------------------------------- ### Get Available Time Slots Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Fetches available time slots for a specific staff member on a given date, optionally filtered by service IDs. Used for the online booking interface. ```bash curl -X GET "https://api.yclients.com/api/v1/book_times/4564/924/2024-06-20?service_ids[]=2838" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN" ``` -------------------------------- ### Get Financial Transactions Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Retrieves a list of financial transactions for a company, with options to filter by date range, cash registers, staff, and clients. Supports pagination. ```bash curl -X GET "https://api.yclients.com/api/v1/transactions/4564?start_date=2024-06-01&end_date=2024-06-30&page=1&count=50" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" ``` -------------------------------- ### User Permissions Management Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Manage user permissions and retrieve available roles within a company. This includes getting a user's current permissions, updating them, and copying user data to other company branches. ```APIDOC ## GET /api/v1/company/{company_id}/users/{user_id}/permissions ### Description Retrieves the full list of a user's permissions. ### Method GET ### Endpoint /api/v1/company/{company_id}/users/{user_id}/permissions ### Request Example ```bash curl -X GET "https://api.yclients.com/api/v1/company/4564/users/123456/permissions" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" ``` ## PUT /api/v1/company/{company_id}/users/{user_id}/permissions ### Description Updates a user's permissions. ### Method PUT ### Endpoint /api/v1/company/{company_id}/users/{user_id}/permissions ### Request Body - **timetable_access** (boolean) - Required - Access to the timetable. - **create_records_access** (boolean) - Required - Access to create records. - **edit_records_access** (boolean) - Required - Access to edit records. - **delete_records_access** (boolean) - Required - Access to delete records. - **clients_access** (boolean) - Required - Access to client information. - **clients_phones_email_access** (boolean) - Required - Access to client phone numbers and emails. - **finances_access** (boolean) - Required - Access to financial information. - **storages_access** (boolean) - Required - Access to storage information. ### Request Example ```bash curl -X PUT "https://api.yclients.com/api/v1/company/4564/users/123456/permissions" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" \ -d { "timetable_access": true, "create_records_access": true, "edit_records_access": true, "delete_records_access": false, "clients_access": true, "clients_phones_email_access": false, "finances_access": false, "storages_access": false } ``` ## GET /api/v1/company/{company_id}/users/roles ### Description Retrieves a list of available roles within a company. ### Method GET ### Endpoint /api/v1/company/{company_id}/users/roles ### Request Example ```bash curl -X GET "https://api.yclients.com/api/v1/company/4564/users/roles" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" ``` ## POST /api/v1/company/{company_id}/users/{user_id}/copy_to_companies ### Description Copies a user's profile and settings to other specified company branches. ### Method POST ### Endpoint /api/v1/company/{company_id}/users/{user_id}/copy_to_companies ### Request Body - **companies** (array of integers) - Required - A list of company IDs to copy the user to. ### Request Example ```bash curl -X POST "https://api.yclients.com/api/v1/company/4564/users/123456/copy_to_companies" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" \ -d { "companies": [4565, 4566, 4567] } ``` ``` -------------------------------- ### Retrieve Booking Form Settings Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Fetches the complete settings for an online booking widget using its ID. Includes configuration for steps, design, language, analytics, and required fields. ```bash curl -X GET "https://api.yclients.com/api/v1/bookform/123" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN" ``` ```json # Response (HTTP 200): # { # "success": true, # "data": { # "steps": [ # { "step": "service", "title": "Выберите услугу", "num": 1, "hidden": "0", "default": -1 }, # { "step": "master", "title": "Выберите специалиста", "num": 2, "hidden": "0", "default": -1 }, # { "step": "datetime","title": "Выберите дату и время", "num": 3, "hidden": false } # ], # "style": { # "show_header": true, # "logo": "https://yclients.com/uploads/logo.png", # "main_color": "666" # }, # "group_id": 0, # "company_id": 4564, # "phone_confirmation": false, # "lang": "ru-RU", # "sms_enabled": true, # "comment_required": false # }, # "meta": [] # } ``` -------------------------------- ### Print Visit Receipt (PDF) Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Generates a PDF receipt for a specific visit. Requires visit_id. ```bash curl -X GET "https://api.yclients.com/api/v1/attendance/receipt_print/8262996" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" ``` -------------------------------- ### Book Client for Group Event Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Books a client into a specific group event. Requires client contact details and the number of attendees. Requires partner token. ```bash curl -X POST "https://api.yclients.com/api/v1/activity/4564/78901/book" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN" \ -d '{ "phone": "79161502239", "fullname": "Мария Иванова", "email": "maria@example.com", "clients_count": 1 }' ``` -------------------------------- ### Copy User to Other Companies Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Copies a user's profile and settings to multiple other companies. Requires the source company ID, source user ID, and a list of target company IDs. ```bash # Копирование пользователя в другие филиалы curl -X POST "https://api.yclients.com/api/v1/company/4564/users/123456/copy_to_companies" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" \ -d '{ "companies": [4565, 4566, 4567] }' ``` -------------------------------- ### Create Online Booking Record Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Create one or more bookings simultaneously for a given company. ```APIDOC ## POST /api/v1/book_record/{company_id} ### Description Creates one or more booking records in a single request for a specified company. The response includes an array of objects, each containing a `record_id` and `record_hash`. ### Method POST ### Endpoint /api/v1/book_record/{company_id} ### Parameters #### Path Parameters - **company_id** (integer) - Required - The ID of the company for which to create the booking. #### Request Body - **phone** (string) - Required - The phone number of the client. - **fullname** (string) - Required - The full name of the client. - **email** (string) - Optional - The email address of the client. - **notify_by_sms** (integer) - Optional - Notification preference via SMS (e.g., 24 for 24 hours before). - **notify_by_email** (integer) - Optional - Notification preference via email (e.g., 2 for 2 hours before). - **comment** (string) - Optional - Any additional comments for the booking. - **appointments** (array) - Required - An array of appointment objects. - **id** (integer) - Required - An identifier for the appointment within the request. - **services** (array) - Required - An array of service IDs. - **staff_id** (integer) - Required - The ID of the staff member. - **datetime** (string) - Required - The date and time of the appointment in ISO 8601 format. - **custom_fields** (object) - Optional - Key-value pairs for custom fields. ### Request Example ```bash curl -X POST "https://api.yclients.com/api/v1/book_record/4564" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN" \ -d '{ "phone": "79161502239", "fullname": "Иван Петров", "email": "ivan@example.com", "notify_by_sms": 24, "notify_by_email": 2, "comment": "Предпочитаю утреннее время", "appointments": [ { "id": 1, "services": [2838, 2840], "staff_id": 924, "datetime": "2024-06-15T10:30:00+03:00", "custom_fields": { "my_custom_field": "значение" } } ] }' ``` ### Response #### Success Response (201) - **id** (integer) - Identifier for the appointment within the request. - **record_id** (integer) - The unique ID of the created booking record. - **record_hash** (string) - A hash representing the booking record. #### Response Example ```json { "success": true, "data": [ { "id": 1, "record_id": 2820023, "record_hash": "567df655304da9b98487769426d4e76e" } ], "meta": [] } ``` ### Error Handling - **432**: Invalid SMS code. - **433**: Time slot is already occupied. - **431**: Invalid phone number format. ``` -------------------------------- ### Create Group Event Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Creates a new group event, specifying details like title, service, staff, date, duration, capacity, and comments. Requires partner and user tokens. ```bash curl -X POST "https://api.yclients.com/api/v1/activity/4564" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" \ -d '{ "title": "Йога для начинающих", "service_id": 2838, "staff_id": 924, "date": "2024-06-25T09:00:00+03:00", "seance_length": 5400, "capacity": 15, "comment": "Принесите коврик" }' ``` -------------------------------- ### Получение списка компаний Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Возвращает список компаний с возможностью фильтрации и добавлением ближайшего свободного времени записи. ```APIDOC ## GET /api/v1/companies ### Description Метод `GET /api/v1/companies` возвращает список компаний с фильтрацией по группе, стране, городу и другим параметрам. Параметр `forBooking=1` добавляет поле `next_slot` с ближайшим свободным временем записи. ### Method GET ### Endpoint `/api/v1/companies` ### Parameters #### Query Parameters - **country_id** (integer) - Optional - Filter by country ID. - **city_id** (integer) - Optional - Filter by city ID. - **forBooking** (integer) - Optional - If set to `1`, includes `next_slot` field in the response. - **count** (integer) - Optional - Number of companies to return per page. Default is usually 10 or 20. - **page** (integer) - Optional - Page number for pagination. Default is 1. ### Request Example ```bash curl -X GET "https://api.yclients.com/api/v1/companies?country_id=1&city_id=1&forBooking=1&count=10&page=1" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN" ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **data** (array) - List of companies. - **id** (integer) - Company ID. - **title** (string) - Company name. - **address** (string) - Company address. - **city** (string) - City where the company is located. - **phone** (string) - Company phone number. - **coordinate_lat** (number) - Latitude coordinate. - **coordinate_lon** (number) - Longitude coordinate. - **active_staff_count** (integer) - Number of active staff members. - **next_slot** (string) - The nearest available booking slot (only if `forBooking=1`). - **phone_confirmation** (boolean) - Indicates if phone confirmation is required. - **allow_change_record** (boolean) - Indicates if records can be changed. - **meta** (object) - Metadata about the response. - **total_count** (integer) - Total number of companies available. #### Response Example ```json { "success": true, "data": [ { "id": 4564, "title": "Студия красоты «Весна»", "address": "ул. Ленина, 10", "city": "Москва", "phone": "+7 916 684-41-22", "coordinate_lat": 55.751244, "coordinate_lon": 37.618423, "active_staff_count": 5, "next_slot": "2024-06-15T10:00:00.000+03:00", "phone_confirmation": false, "allow_change_record": true } ], "meta": { "total_count": 42 } } ``` ``` -------------------------------- ### Create Custom Field Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Creates a new custom field for clients or appointments. Supports types like text, number, select, date, and datetime. Requires partner and user tokens. ```bash curl -X POST "https://api.yclients.com/api/v1/company/4564/custom_fields" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" \ -d '{ "title": "Источник", "code": "source_channel", "type": "select", "entity": "client", "show_in_ui": true, "user_can_edit": true, "values": ["Сайт", "Телефон", "Рекомендация", "Соцсети"] }' ``` -------------------------------- ### Transfer Booking with PUT /api/v1/book_record Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Use this method to move an existing booking to a different time. It requires partner authorization and does not need a user token. ```bash curl -X PUT "https://api.yclients.com/api/v1/book_record/4564/2820023" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN" \ -d '{ "staff_id": 924, "datetime": "2024-06-16T14:00:00+03:00" }' ``` -------------------------------- ### Create Financial Transaction Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Creates a new financial transaction. Requires details such as account, expense type, amount, comment, date, and associated staff/client IDs. ```bash curl -X POST "https://api.yclients.com/api/v1/transactions/4564" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" \ -d '{ "account_id": 101, "expense_id": 5, "amount": 5000.00, "comment": "Оплата за услуги", "date": "2024-06-15T12:00:00+03:00", "master_id": 924, "client_id": 1121412 }' ``` -------------------------------- ### Send Email Campaign by Filter Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Sends an email campaign to clients filtered by specific criteria, such as last visit date. Requires partner and user tokens for authorization. ```bash curl -X POST "https://api.yclients.com/api/v1/email/clients/by_filter/4564" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" \ -d '{ "subject": "Мы скучаем по вам!", "message": "

Добро пожаловать обратно!

Запишитесь к нам со скидкой 15%.

", "filters": { "last_visit_date_to": "2024-04-15" } }' ``` -------------------------------- ### Create Online Booking Record Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Creates one or more bookings in a single request. Returns an array of objects with `record_id` and `record_hash`. Handles errors for invalid SMS codes (432), busy times (433), and incorrect phone formats (431). ```bash curl -X POST "https://api.yclients.com/api/v1/book_record/4564" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN" \ -d '{ "phone": "79161502239", "fullname": "Иван Петров", "email": "ivan@example.com", "notify_by_sms": 24, "notify_by_email": 2, "comment": "Предпочитаю утреннее время", "appointments": [ { "id": 1, "services": [2838, 2840], "staff_id": 924, "datetime": "2024-06-15T10:30:00+03:00", "custom_fields": { "my_custom_field": "значение" } } ] }' ``` ```json # Response (HTTP 201): # { # "success": true, # "data": [ # { # "id": 1, # "record_id": 2820023, # "record_hash": "567df655304da9b98487769426d4e76e" # } # ], # "meta": [] # } ``` -------------------------------- ### Booking Form Settings Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Retrieve the complete settings for an online booking widget using its ID. ```APIDOC ## GET /api/v1/bookform/{id} ### Description Retrieves the full configuration of the online booking widget based on its identifier. This includes step order, design preferences, language settings, analytics configurations, and mandatory field flags. ### Method GET ### Endpoint /api/v1/bookform/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The unique identifier of the booking form. ### Request Example ```bash curl -X GET "https://api.yclients.com/api/v1/bookform/123" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN" ``` ### Response #### Success Response (200) - **steps** (array) - Configuration for each step in the booking process. - **style** (object) - Visual styling options for the widget. - **group_id** (integer) - The ID of the associated group. - **company_id** (integer) - The ID of the company. - **phone_confirmation** (boolean) - Whether phone confirmation is enabled. - **lang** (string) - The language code for the widget. - **sms_enabled** (boolean) - Whether SMS notifications are enabled. - **comment_required** (boolean) - Whether a comment is required from the user. #### Response Example ```json { "success": true, "data": { "steps": [ { "step": "service", "title": "Выберите услугу", "num": 1, "hidden": "0", "default": -1 }, { "step": "master", "title": "Выберите специалиста", "num": 2, "hidden": "0", "default": -1 }, { "step": "datetime","title": "Выберите дату и время", "num": 3, "hidden": false } ], "style": { "show_header": true, "logo": "https://yclients.com/uploads/logo.png", "main_color": "666" }, "group_id": 0, "company_id": 4564, "phone_confirmation": false, "lang": "ru-RU", "sms_enabled": true, "comment_required": false }, "meta": [] } ``` ``` -------------------------------- ### Validate Appointment Parameters Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Checks the validity of appointment parameters before creating a booking. Requires the company ID and appointment details in the request body. An HTTP 422 response indicates an issue, such as a conflict. ```bash # Проверка параметров записи curl -X POST "https://api.yclients.com/api/v1/book_check/4564" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN" \ -d '{ "appointments": [ { "id": 1, "staff_id": 924, "services": [2838], "datetime": "2024-06-20T10:30:00+03:00" } ] }' ``` -------------------------------- ### Получение и создание клиентов Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Получает список клиентов компании с поддержкой поиска и пагинации, а также добавляет нового клиента. ```APIDOC ## GET /api/v1/clients/{company_id} ### Description Метод `GET /api/v1/clients/{company_id}` возвращает список клиентов компании с поддержкой поиска и пагинации. ### Method GET ### Endpoint `/api/v1/clients/{company_id}` ### Parameters #### Path Parameters - **company_id** (integer) - Required - The ID of the company. #### Query Parameters - **page** (integer) - Optional - Page number for pagination. - **count** (integer) - Optional - Number of clients to return per page. - **search** (string) - Optional - Search query for clients (e.g., by name or phone). ### Request Example ```bash curl -X GET "https://api.yclients.com/api/v1/clients/4564?page=1&count=20&search=Иван" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" ``` ## POST /api/v1/clients/{company_id} ### Description Метод `POST /api/v1/clients/{company_id}` добавляет нового клиента. ### Method POST ### Endpoint `/api/v1/clients/{company_id}` ### Parameters #### Path Parameters - **company_id** (integer) - Required - The ID of the company. #### Request Body - **name** (string) - Required - Client's first name. - **surname** (string) - Optional - Client's last name. - **phone** (integer) - Required - Client's phone number. - **email** (string) - Optional - Client's email address. - **sex_id** (integer) - Optional - Sex identifier (e.g., 1 for male, 2 for female). - **importance_id** (integer) - Optional - Importance level identifier. - **discount** (integer) - Optional - Client's discount percentage. - **birth_date** (string) - Optional - Client's birth date in `YYYY-MM-DD` format. - **comment** (string) - Optional - Any comments about the client. - **sms_check** (integer) - Optional - Flag for SMS verification (1 for enabled, 0 for disabled). - **sms_not** (integer) - Optional - Flag for SMS notifications (1 for enabled, 0 for disabled). - **categories** (array) - Optional - Array of category IDs the client belongs to. - **id** (integer) - **custom_fields** (object) - Optional - Key-value pairs for custom fields. ### Request Example ```bash curl -X POST "https://api.yclients.com/api/v1/clients/4564" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" \ -d '{ \ "name": "Василий", \ "surname": "Сонов", \ "phone": 79211234567, \ "email": "vasiliy@example.com", \ "sex_id": 1, \ "importance_id": 1, \ "discount": 10, \ "birth_date": "1990-05-15", \ "comment": "Постоянный клиент", \ "sms_check": 1, \ "sms_not": 0, \ "categories": [101, 102], \ "custom_fields": { "source": "website" } \ }' ``` ### Response #### Success Response (201 for POST, 200 for GET) - **success** (boolean) - Indicates if the operation was successful. - **data** (object/array) - For POST, contains details of the created client. For GET, contains a list of clients. - **id** (integer) - Client ID. - **name** (string) - Client's first name. - **phone** (integer) - Client's phone number. - **email** (string) - Client's email address. - **sex** (string) - Client's sex. - **importance** (string) - Client's importance level. - **visits** (integer) - Number of visits. - **spent** (integer) - Total amount spent. - **meta** (array) - Additional metadata. #### Response Example (POST) ```json { "success": true, "data": { "id": 1121412, "name": "Василий", "phone": 79211234567, "email": "vasiliy@example.com", "sex": "Мужской", "importance": "Бронза", "visits": 0, "spent": 0 }, "meta": [] } ``` ``` -------------------------------- ### Search Group Events Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Searches for available group events within a specified date range and optionally filters by service IDs. Requires partner token. ```bash curl -X GET "https://api.yclients.com/api/v1/activity/4564/search?start_date=2024-06-20&end_date=2024-06-30&service_ids[]=2838" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN" ``` -------------------------------- ### Custom Fields Management Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Manage custom fields for clients and appointments, including retrieving existing fields and creating new ones. ```APIDOC ## GET /api/v1/company/{company_id}/custom_fields ### Description Retrieves the list of custom fields configured for a company. ### Method GET ### Endpoint /api/v1/company/{company_id}/custom_fields ### Parameters #### Path Parameters - **company_id** (integer) - Required - The ID of the company. ## POST /api/v1/company/{company_id}/custom_fields ### Description Creates a new custom field for a company. ### Method POST ### Endpoint /api/v1/company/{company_id}/custom_fields ### Parameters #### Path Parameters - **company_id** (integer) - Required - The ID of the company. #### Request Body - **title** (string) - Required - The title of the custom field. - **code** (string) - Required - A unique code for the custom field. - **type** (string) - Required - The type of the custom field (e.g., `text`, `number`, `select`, `date`, `datetime`). - **entity** (string) - Required - The entity the field applies to (e.g., `client`, `record`). - **show_in_ui** (boolean) - Optional - Whether to show the field in the UI. - **user_can_edit** (boolean) - Optional - Whether the user can edit the field. - **values** (array) - Optional - A list of possible values for `select` type fields. ### Request Example ```json { "title": "Источник", "code": "source_channel", "type": "select", "entity": "client", "show_in_ui": true, "user_can_edit": true, "values": ["Сайт", "Телефон", "Рекомендация", "Соцсети"] } ``` ### Usage Example (Client Creation) ```json "custom_fields": { "source_channel": "Сайт" } ``` ``` -------------------------------- ### Send SMS to Clients by ID Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Sends an SMS message to a specified list of client IDs. Requires a list of client IDs and the message content. ```bash curl -X POST "https://api.yclients.com/api/v1/sms/clients/by_id/4564" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" \ -d '{ "client_ids": [1121412, 1121413, 1121414], "message": "Уважаемый клиент! Напоминаем о вашей записи завтра в 10:00." }' ``` -------------------------------- ### Issue Loyalty Card Source: https://context7.com/alexmaltsevgit/yclients-openapi/llms.txt Issues a new loyalty card to a client. Requires specifying the client ID, card type, and card number. Requires partner and user tokens. ```bash curl -X POST "https://api.yclients.com/api/v1/loyalty/cards/4564" \ -H "Accept: application/vnd.yclients.v2+json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_PARTNER_TOKEN, User YOUR_USER_TOKEN" \ -d '{ "client_id": 1121412, "type_id": 7, "number": "CARD-001-2024" }' ```