Integrate your external CRM system with the B2COPY API

Learn how to authorize in B2COPY from your external CRM system and obtain the access token required for using the B2COPY API

This guide explains how to integrate your external CRM system with B2COPY to authorize in B2COPY, obtain an access token for API requests, and initiate fee processing between master and investment accounts.

Prerequisites

  • Create a service admin in the Admin panel, on whose behalf your external CRM system will make API requests to B2COPY.

It's recommended to explicitly specify the list of IP addresses from which the external CRM system will send requests for this service admin.

  • Configure your external CRM system to generate signed JWT tokens. Each token must include the following claims:

    • admin_id — the identifier of the created service admin for whom the JWT token is issued.

    • device_ip — the IP address from which the request is made.

    • key_id — the identifier of the private key.

Generate keys

Run the following OpenSSL commands to generate an EC (Elliptic Curve) private and public key pair for signing and verifying JWT tokens:

# Generate private key
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 \
    -out ec_private_pkcs8.pem

# Generate public key
openssl pkey -in ec_private_pkcs8.pem \
    -pubout -out ec_public.pem

Security note

Contact B2COPY support

To complete the integration, provide the following to the B2COPY support team:

  • Your public key (ec_public.pem).

  • The unique key identifier.

  • The IP addresses from which requests to the B2COPY API will be made.

The B2COPY support team will register your integration, configure your public key in the system, and provide further instructions to enable API authorization.

Generate JWT tokens

Use the following Java code to generate and sign JWT tokens with your private key. The token includes the admin_id and device_ip claims and is signed using the ES256 algorithm.

Obtain B2COPY access and refresh tokens

To obtain a pair of access and refresh tokens from B2COPY, use the following method:

POST [host]/api/admin/auth/v2/admin/adminservice/authexternalcrm

Request

Body parameters

Name
Type
Required
Description

external_token

string

Yes

The generated JWT token.

Request example

Response

The response returns access and refresh tokens for the service admin specified in the token claims. All other API requests to B2COPY must include the obtained access token in the Authorization header.

Response example

Refresh the access token

To refresh the expired access token, use the following method:

POST [host]/api/admin/auth/v2/admin/adminservice/refreshtoken

Request

Request example

Response

The response returns a new pair of access and refresh tokens.

Initiate fee processing between master and investment accounts

To initiate fee calculation and deduction from investment accounts subscribed to a specific master account, use the following method:

POST [host]/api/admin/fees/v2/fee/feeservice/processext

Request

Body parameters

Name
Type
Required
Description

account_login

string

Yes

The account login (number).

request_id

string

Yes

The identifier of a withdrawal request initiated in the external CRM system.

Key points about request_id

Request example

Response

The response returns the status of the initiated fee processing.

Response example

Possible statuses:

  • 1 —FEE_PROCESS_STATUS_PENDING: the request is being processed (temporary status).

    Fee payments from investment accounts to the master account are in progress. After receiving this status, start monitoring by using polling.

  • 2 — FEE_PROCESS_STATUS_SUCCESS: the request completed successfully (final status).

    All fees have been paid from investment accounts to the master account. No further action is required.

If no fee deduction is required for the account, the response returns FEE_PROCESS_STATUS_SUCCESS immediately without going through the PENDING status.

  • 3 — FEE_PROCESS_STATUS_ERROR: an error occurred during request processing (final status).

    Check the error details and retry if necessary.

Polling implementation

The FEE_PROCESS_STATUS_PENDING status is temporary and indicates that B2COPY is actively processing fee payments between accounts. Implement polling as follows:

  1. After make the initial request with account_login and request_id and receiving the FEE_PROCESS_STATUS_PENDING status, wait 3-5 seconds.

  2. Repeat the request with the same request_id.

  3. Continue polling until you receive FEE_PROCESS_STATUS_SUCCESS or FEE_PROCESS_STATUS_ERROR.

Polling example

Last updated

Was this helpful?