Module mft
API
Declarations
Definitions

ballerinax/mft Ballerina library
Overview
This is a generated connector for MFT REST API v1.0 OpenAPI specification. The MFT REST API provides a secure AS2 secured channel for such communications, and offers your company, multiple ways to upload/download files, or automate the exchange through integration mechanisms.
Prerequisites
Before using this connector in your Ballerina application, complete the following:
- Create a MFT account
- Obtain tokens following this guide.
Quickstart
To use the MFT connector in your Ballerina application, update the .bal file as follows
Step 1: Import connector
First, import the ballerinax/mft module into the Ballerina project.
import ballerinax/mft;
Step 2: Create a new connector instance
Create a mft:Client instance using an API token.
mft:Client mftClient = check new ({authorization: <VALID_API_TOKEN>});
Step 3: Invoke connector operation
- 
Now you can use the operations available within the connector. Note that they are in the form of remote operations. Following is an example on listing received messages. List Received Messages public function main() { SuccessfulMessageListRetrievalResponse messageResponse = check mftClient->listReceivedMessages(); if messageResponse.messages == [] { io:println("No messages received!!"); return; } foreach var message in messageResponse.messages { io:println("MESSAGE ID >>>" +message.toString()); } }Following is an example on single message retrieval. Retrieve an Inbox (Received) Message public function main() { AS2Message messageResponse2 = check mftClient->retrieveInboxMessage(messageResponse1.messages[0]); io:println(">>>", messageResponse2); }Following is an example on listing certificates available. List Certificates public function main() { SuccessfulCertListRetrievalResponse listCertificates = check mftClient->listCertificates(); io:println(listCertificates); }
- 
Use bal runcommand to compile and run the Ballerina program.
Clients
mft: Client
This is a generated connector for MFT REST API v1.0 OpenAPI specification. The MFT REST API provides a secure AS2 secured channel for such communications, and offers your company, multiple ways to upload/download files, or automate the exchange through integration mechanisms.
Constructor
Gets invoked to initialize the connector.
The connector initialization requires setting the API credentials.
Create a MFT account and obtain tokens following this guide.
init (ApiKeysConfig apiKeyConfig, ClientConfiguration clientConfig, string serviceUrl)- apiKeyConfig ApiKeysConfig - API keys for authorization
- clientConfig ClientConfiguration {} - The configurations to be used when initializing the connector
- serviceUrl string "https://api.mftgateway.com" - URL of the target service
sendMessage
function sendMessage(string as2From, string as2To, string contentType, MessageSubmitBody payload, string? subject, string? attachmentName) returns SuccessfulMessageSubmitResponse|errorSend Message
Parameters
- as2From string - Station AS2 identifier which sends the message
- as2To string - Partner AS2 identifier which intends to receive the message
- contentType string - Content type of the message payload. For multiple attachments, content type should be multipart/form-data with valid form content
- payload MessageSubmitBody - File body as byte array
- subject string? (default ()) - Subject of the message. If not specified, the default subject configured for the intended partner will be applied.
- attachmentName string? (default ()) - Name of the message attachment (Only applicable when sending a message with single attachment)
Return Type
- SuccessfulMessageSubmitResponse|error - Accepted for Processing
listReceivedMessages
function listReceivedMessages(string sortDir, int pageLength, int pageOffset, string? stationAS2Id, string? partnerAS2Id, string? as2MessageId, string? subject, boolean fetchAll) returns SuccessfulMessageListRetrievalResponse|errorList Received Messages
Parameters
- sortDir string (default "desc") - Sort direction of messages
- pageLength int (default 10) - Length of a page. An integer value greater than or equal to 1 and less than or equal to 100 is accepted.
- pageOffset int (default 0) - Page offset, supports non-negative integer values
- stationAS2Id string? (default ()) - AS2 identifier of the AS2 Station that received these messages
- partnerAS2Id string? (default ()) - AS2 identifier of the AS2 Partner that sent these messages
- as2MessageId string? (default ()) - AS2 message identifier of the required AS2 message(s)
- subject string? (default ()) - Any subject string to filter messages against
- fetchAll boolean (default false) - Fetch all messages including already been "marked as read" within the API scope
Return Type
- SuccessfulMessageListRetrievalResponse|error - Successful
retrieveInboxMessage
function retrieveInboxMessage(string as2MessageId, boolean markAsRead) returns AS2Message|errorRetrieve an Inbox (Received) Message
Parameters
- as2MessageId string - AS2 ID of the message to be retrieved
- markAsRead boolean (default true) - If this is set to true, the message will be "marked as read" upon retrieval. Any message list queries with fetchAllquery param set tofalse, will not return the corresponding message afterwards. You can combine this and thefetchAllquery parameter, to ensure one-time processing of received messages. (Note that this marking will be applied only at API scope; "marked as read" messages may still appear as unread on the MFT Gateway webapp inbox.)
Return Type
- AS2Message|error - Successfully Retrieved
deleteInboxMessage
function deleteInboxMessage(string as2MessageId) returns SuccessfulMessageDeletionResponse|errorDelete Inbox (Received) Message
Parameters
- as2MessageId string - AS2 ID of the message to be deleted
Return Type
- SuccessfulMessageDeletionResponse|error - Successfully Deleted
markReceivedMessageAsUnRead
function markReceivedMessageAsUnRead(string as2MessageId) returns ResponseWithMessage|errorMark Received Message As UnRead
Parameters
- as2MessageId string - AS2 ID of the message to be marked as unread
Return Type
- ResponseWithMessage|error - Successfully marked as Unread
retrieveInboxMessageAttachments
function retrieveInboxMessageAttachments(string as2MessageId) returns SuccessfulAttachmentListResponse|errorRetrieve Inbox (Received) Message Attachment(s)
Parameters
- as2MessageId string - AS2 ID of the message to retrieve attachments of
Return Type
- SuccessfulAttachmentListResponse|error - Successfully Retrieved
retrieveInboxMessageMDN
function retrieveInboxMessageMDN(string as2MessageId) returns SuccessfulMDNRetrievalResponse|errorRetrieve Inbox (Received) Message MDN
Parameters
- as2MessageId string - AS2 ID of the message to retrieve MDN of
Return Type
- SuccessfulMDNRetrievalResponse|error - Successfully Retrieved
batchDeleteInboxMessages
function batchDeleteInboxMessages(MessageBatchOperationRequest payload) returns SuccessfulMessageBatchDeletionResponse|errorBatch Delete Inbox (Received) Messages
Parameters
- payload MessageBatchOperationRequest - AS2 IDs of the messages to be deleted
Return Type
- SuccessfulMessageBatchDeletionResponse|error - Successfully Deleted
listSentMessages
function listSentMessages(string sortDir, int pageLength, int pageOffset, string? stationAS2Id, string? partnerAS2Id, string? as2MessageId, string? subject) returns SuccessfulMessageListRetrievalResponse|errorList Sent Messages
Parameters
- sortDir string (default "desc") - Sort direction of messages
- pageLength int (default 10) - Length of a page. An integer value greater than or equal to 1 and less than or equal to 100 is accepted.
- pageOffset int (default 0) - Page offset, supports non-negative integer values
- stationAS2Id string? (default ()) - AS2 identifier of the AS2 Station that sent these messages
- partnerAS2Id string? (default ()) - AS2 identifier of the AS2 Partner that received these messages
- as2MessageId string? (default ()) - AS2 message identifier of the required AS2 message(s)
- subject string? (default ()) - Any subject string to filter messages against
Return Type
- SuccessfulMessageListRetrievalResponse|error - Successful
listQueuedMessages
function listQueuedMessages(string sortDir, int pageLength, int pageOffset, string? stationAS2Id, string? partnerAS2Id, string? as2MessageId, string? subject) returns SuccessfulMessageListRetrievalResponse|errorList Queued Messages
Parameters
- sortDir string (default "desc") - Sort direction of messages
- pageLength int (default 10) - Length of a page. An integer value greater than or equal to 1 and less than or equal to 100 is accepted.
- pageOffset int (default 0) - Page offset, supports non-negative integer values
- stationAS2Id string? (default ()) - AS2 identifier of the AS2 Station that will be sending these messages
- partnerAS2Id string? (default ()) - AS2 identifier of the AS2 Partner that will be receiving these messages
- as2MessageId string? (default ()) - AS2 message identifier of the required AS2 message(s)
- subject string? (default ()) - Any subject string to filter messages against
Return Type
- SuccessfulMessageListRetrievalResponse|error - Successful
listFailedMessages
function listFailedMessages(string sortDir, int pageLength, int pageOffset, string? stationAS2Id, string? partnerAS2Id, string? as2MessageId, string? subject) returns SuccessfulMessageListRetrievalResponse|errorList Failed Messages
Parameters
- sortDir string (default "desc") - Sort direction of messages
- pageLength int (default 10) - Length of a page. An integer value greater than or equal to 1 and less than or equal to 100 is accepted.
- pageOffset int (default 0) - Page offset, supports non-negative integer values
- stationAS2Id string? (default ()) - AS2 identifier of the AS2 Station that that was intended to sent these messages
- partnerAS2Id string? (default ()) - AS2 identifier of the AS2 Partner that was intended to receive these messages
- as2MessageId string? (default ()) - AS2 message identifier of the required AS2 message(s)
- subject string? (default ()) - Any subject string to filter messages against
Return Type
- SuccessfulMessageListRetrievalResponse|error - Successful
listincompletedmessages
function listincompletedmessages(string sortDir, int pageLength, int pageOffset, string? stationAS2Id, string? partnerAS2Id, string? as2MessageId, string? subject) returns SuccessfulMessageListRetrievalResponse|errorList Incompleted Messages
Parameters
- sortDir string (default "desc") - Sort direction of messages
- pageLength int (default 10) - Length of a page. An integer value greater than or equal to 1 and less than or equal to 100 is accepted.
- pageOffset int (default 0) - Page offset, supports non-negative integer values
- stationAS2Id string? (default ()) - AS2 identifier of the AS2 Station that sent these messages
- partnerAS2Id string? (default ()) - AS2 identifier of the AS2 Partner that received these messages
- as2MessageId string? (default ()) - AS2 message identifier of the required AS2 message(s)
- subject string? (default ()) - Any subject string to filter messages against
Return Type
- SuccessfulMessageListRetrievalResponse|error - Successful
retrieveOutboxMessage
function retrieveOutboxMessage(string as2MessageId) returns AS2Message|errorRetrieve Outbox (Sent/Queued/Failed/Incomplete) Message
Parameters
- as2MessageId string - AS2 ID of the message to be retrieved
Return Type
- AS2Message|error - Successfully Retrieved
deleteOutboxMessage
function deleteOutboxMessage(string as2MessageId) returns SuccessfulMessageDeletionResponse|errorDelete Outbox (Sent/Queued/Failed) Message
Parameters
- as2MessageId string - AS2 ID of the message to be deleted
Return Type
- SuccessfulMessageDeletionResponse|error - Successfully Deleted
retrieveOutboxMessageAttachments
function retrieveOutboxMessageAttachments(string as2MessageId) returns SuccessfulAttachmentListResponse|errorRetrieve Outbox (Sent/Queued/Failed) Message Attachment(s)
Parameters
- as2MessageId string - AS2 ID of the message to retrieve attachments of
Return Type
- SuccessfulAttachmentListResponse|error - Successfully Retrieved
retrieveOutboxMessageMDN
function retrieveOutboxMessageMDN(string as2MessageId) returns SuccessfulMDNRetrievalResponse|errorRetrieve Outbox (Sent/Queued/Failed) Message MDN
Parameters
- as2MessageId string - AS2 ID of the message to retrieve MDN of
Return Type
- SuccessfulMDNRetrievalResponse|error - Successfully Retrieved
batchDeleteOutboxMessages
function batchDeleteOutboxMessages(MessageBatchOperationRequest payload) returns SuccessfulMessageBatchDeletionResponse|errorBatch Delete Outbox (Sent/Queued/Failed) Messages
Parameters
- payload MessageBatchOperationRequest - AS2 IDs of the messages to be deleted
Return Type
- SuccessfulMessageBatchDeletionResponse|error - Successfully Deleted
listCertificates
function listCertificates(string? certType) returns SuccessfulCertListRetrievalResponse|errorList Certificates
Parameters
- certType string? (default ()) - Certificate type to filter. Allowed values: 'STATION', 'PARTNER', 'HTTPS', 'PARTNER_CHAIN' and 'HTTPS_CHAIN' Defaults to null (all certificates)
Return Type
- SuccessfulCertListRetrievalResponse|error - Successful Certificate List Retrieval
retrieveCertificateMetadata
function retrieveCertificateMetadata(string alias) returns SuccessfulCertRetrievalResponse|errorRetrieve Certificate Metadata
Parameters
- alias string - Alias of the certificate to retrieve
Return Type
- SuccessfulCertRetrievalResponse|error - A certificate with given alias found
createStation
function createStation(CreateStationRequest payload) returns SuccessfulStationCreationResponse|errorCreate Station
Parameters
- payload CreateStationRequest - Station metadata in form on a record CreateStationRequest
Return Type
- SuccessfulStationCreationResponse|error - Successfully Created
createPartner
function createPartner(CreatePartnerRequest payload) returns SuccessfulPartnerCreationResponse|errorCreate Partner
Parameters
- payload CreatePartnerRequest - Partner metadata in form on a record
Return Type
- SuccessfulPartnerCreationResponse|error - Successfully Created
Enums
mft: CertificateType
Members
Records
mft: ApiKeysConfig
Provides API key configurations needed when communicating with a remote HTTP endpoint.
Fields
- authorization string - Auth token retrieved from authorization endpoint or refresh token endpoint
mft: AS2Message
Fields
- id int -
- as2MessageId string -
- incoming boolean -
- msgStatus string -
- mdnStatus string -
- receiverAS2Id string -
- senderAS2Id string -
- subject string -
- failures int -
- attachmentPaths string[] -
- compressed boolean -
- signed boolean -
- encrypted boolean -
- mic string -
- micMatches boolean -
- transportStatusReceived int -
- userAgent string -
- timestamp int -
- apiFetched boolean -
- transportHeaders? TransportHeader -
- mdnMessage? MdnMessage -
mft: Attachment
Fields
- name string -
- url string -
mft: AuthorizeRequest
Fields
- username string -
- password string -
mft: CertificateFromCertStoreForStation
Fields
- 'type CertificateType(default FROM_CERTIFICATE_STORE) - Certificate configuration type
- alias string - Existing MFT Gateway IDENTITY type certificate alias
mft: CertificateFromKeystoreForStation
Fields
- 'type CertificateType(default FROM_KEYSTORE) - Certificate configuration type
- keystore string - S3 key of the existing keystore in your MFT Gateway S3 bucket
- keystorePassword string - Keystore password
- alias string - Certificate alias
- privateKeyPassword string - Existing private key password
- newPrivateKeyPassword? string - New private key password. If not provided, the existing private key password will be used as new password.
mft: CreatePartnerRequest
Fields
- name string -
- as2Identifier string -
- description? string -
- url string - Trading partner message delivery endpoint
- encryptionCertificate string - Base64 encoded encryption certificate
- encryptMessage? boolean - Whether to encrypt outbound messages
- encryptionAlgorithm? string - Encryption algorithm to be used
- signMessage? boolean - Whether to sign outbound messages
- signatureAlgorithm? string - Signature algorithm to be used
- useDiffCertAsSignCert? boolean - Whether to use a different certificate to verify signature of the inbound messages. If set to false, encryptionCertificate will be used to validate incoming message signatures.
- signatureCertificate? string - Base64 encoded signature certificate (Required if useDiffCertAsSignCert set to true)
- httpsCertificate? string - Base64 encoded SSL certificate
- encryptSignChainCertificates? string[] - Base64 encoded encryption/sign chain certificate(s)
- httpsChainCertificates? string[] - Base64 encoded SSL chain certificate(s)
- validateTrustAnchor? boolean - Whether to validate trust anchor of the uploaded certificates
- messageSubject? string - Default message subject for trading partner
- compressBefore? boolean - Whether to compress messages before encryption/sign
- compressAfter? boolean - Whether to compress messages after encryption/sign
- requestMDN? boolean - Whether to request Message Disposition Notification
- requestSignedMDN? boolean - Whether to request signed Message Disposition Notification
- requestAsyncMDN? boolean - Whether to request asynchronous Disposition Notification
- useStaticIP? boolean - Whether to use Static IP for outbound messages (Business/Enterprise tier feature)
- transmissionTimeout? int - Maximum waiting time (in seconds) before closing the outbound connection
- deleteAttachmentsOnSuccessMdn? boolean - Whether to delete Attachments from the S3 bucket when a success MDN is received
- autoRetryIncompleteMessages? boolean - Whether to auto retry incomplete messages.
Incomplete messages may have successfully processed by the trading partner but failed to acknowledge before
the configured timeout. If sets to truethere is a possibility of duplicating outbound messages.
- customHeaders? CreatepartnerrequestCustomheaders[] - Custom transport headers to be included in the outbound messages to this trading partner. Following header names are reserved and cannot be used. 'as2-from', 'as2-to', 'as2-version', 'content-transfer-encoding', 'content-type', 'disposition-notification-options', 'mime-version', 'message-id', 'receipt-delivery-option', 'destination'
mft: CreatepartnerrequestCustomheaders
Fields
- headerName string -
- headerValue string -
mft: CreateStationRequest
Fields
- name string -
- as2Identifier string -
- email string - Comma separated list of emails (up to maximum of 3 emails)
- certificate NewCertificateForStation|CertificateFromKeystoreForStation|CertificateFromCertStoreForStation - Nested JSON object with station identity certificate configuration
- description? string -
- receivedMessageNotifications? boolean - Whether to enable email notifications for received messages
- failedMessageNotifications? boolean - Whether to enable email notifications for send failures
- largePayloadSupport? boolean - Whether to receive messages with payload size larger than 3MB through static IP address (Business/Enterprise tier feature)
mft: CreationErrorResponse
Fields
- message string -
- errors RequestFieldError[] -
mft: MdnMessage
Fields
- mdnId string -
- messageId int -
- as2MessageId string -
- disposition string -
- humanMessage string -
- rawMdnS3Key string -
- mic string -
- signed boolean -
- incoming boolean -
- status string -
- timestamp int -
mft: MessageBatchOperationRequest
Fields
- as2MessageIds string[] - AS2 IDs of the messages
mft: MessageSubmitBody
Fields
- File byte[] -
mft: NewCertificateForStation
Fields
- 'type CertificateType(default NEW_SELF_SIGN_CERTIFICATE) - Certificate configuration type
- commonName string - Certificate Common Name
- password string - Private key password
- keyLength int - Certificate key length
- validity int - Certificate validity in years
- orgUnit? string - Organization unit
- orgName? string - Organization name
- city? string - City
- state? string - State code ISO 3166-1 alpha-2
- country? string - Country code ISO 3166-1 alpha-2
mft: RefreshAuthTokenRequest
Fields
- username string -
- refreshToken string -
mft: RequestFieldError
mft: ResponseWithMessage
Fields
- message string -
mft: SuccessfulAttachmentListResponse
Fields
- total int -
- attachments Attachment[] -
mft: SuccessfulAuthorizationResponse
Fields
- api_token string -
- refresh_token string -
mft: SuccessfulcertlistretrievalresponseInner
Fields
- alias? string -
- 'type? string -
mft: SuccessfulCertRetrievalResponse
Fields
- alias string -
- 'type string -
- serial_number string -
- subject_common_name string -
- subject_distinguish_name string -
- issuer_common_name string -
- issuer_distinguish_name string -
- valid_from string -
- expiry string -
- belongsTo string[] - To which entities this certificate belongs to
mft: SuccessfulMDNRetrievalResponse
Fields
- url string -
mft: SuccessfulMessageBatchDeletionResponse
Fields
- deleted string[] - AS2 IDs of the deleted messages
mft: SuccessfulMessageDeletionResponse
Fields
- deleted string - AS2 ID of the deleted message
mft: SuccessfulMessageListRetrievalResponse
Fields
- messages string[] - Array of AS2 IDs of the messages
mft: SuccessfulMessageSubmitResponse
Fields
- message string -
- as2MessageId string -
mft: SuccessfulPartnerCreationResponse
Fields
- message string -
- partnerId? int -
mft: SuccessfulStationCreationResponse
Fields
- message string -
- stationId? int -
mft: TransportHeader
Fields
- 'AS2\-From string -
- 'User\-Agent string -
- 'Accept\-Encoding? string -
- 'Content\-Transfer\-Encoding? string -
- 'Message\-ID? string -
- 'Disposition\-Notification\-Options? string -
- 'AS2\-To string -
- 'Content\-Type string -
- 'Disposition\-Notification\-To? string -
- 'AS2\-Version string -
- Host? string -
- From string -
- 'MIME\-Version string -
- Subject string -
Array types
mft: SuccessfulCertListRetrievalResponse
SuccessfulCertListRetrievalResponse
Import
import ballerinax/mft;Other versions
1.0.0
Metadata
Released date: over 3 years ago
Version: 1.0.0
License: Apache-2.0
Compatibility
Platform: any
Ballerina version: 2201.0.2
GraalVM compatible: Yes
Pull count
Total: 0
Current verison: 0
Weekly downloads
Keywords
IT Operations/Message Brokers
Cost/Freemium
Contributors