How to send AS2 messages with an EDI trading platform | Aayu Technologies
Home Blog How to send AS2 messages with an EDI trading platform

How to send AS2 messages with an EDI trading platform

AS2 Gateway is a SaaS EDI trading platform which is created based on AS2 protocol to provide secure, reliable and faster communication for B2B enterprises

28 Sep 2022

When the business involves lots of confidential data, security will be a major concern for all enterprises. Therefore, going for an EDI trading platform with a secure file transfer protocol is essential. AS2 Gateway is a SaaS EDI trading platform which is created based on AS2 protocol to provide secure, reliable and faster communication for B2B enterprises. In addition to all the benefits packaged with AS2 protocol, AS2 Gateway itself provides a flexible, easy-to-use, personalized piece of software to the customers. So, in this article let’s talk about how to send AS2 messages via AS2 Gateway.

How to create an account in AS2 Gateway

To get started with AS2 Gateway, you have to register your organization by giving few details like domain name, name, administrator’s name, email address, etc.

AS2 gateway Register Open image on lightbox

Once you have submitted the details, an account in AS2 Gateway will be created for your organization. When you log in, you will see a dashboard view where users can monitor the number of messages transferred within a particular period with graphical representations.

AS2 gateway Dashboard Open image on lightbox

How to create a station

To start sending messages via AS2 Gateway, you have to create a trading station for your organization which will act as your local endpoint. To configure a station, go to ‘Stations’ UI and click ‘New Station’ button.

AS2 gateway Station Creation Open image on lightbox

In Station configuration UI, provide a name to your trading station, and a unique AS2 identifier to use in messaging. Then you have to provide an email address which can also be used to get notifications for receiving messages of the station. You can also state a small description of your station.

AS2 Gateway provides 3 options to configure a certificate for the station.

  • Generate New Key Store: AS2 Gateway will create a key store on behalf of you
  • Upload Existing Key Store: a key store in your local machine can be uploaded
  • Select from Certificate Store: a certificate that already exists in your AS2 Gateway account

Once you have submitted the form, the station will be created and will appear in ‘Stations’ UI as below.

AS2 gateway Station Open image on lightbox

On the station block, you can see 4 icons as below.

  1. Manage Station: where you can view and edit station details
  2. View Partner Configuration: where you can find configuration details like AS2 identifier, the message receiving URLs, certificates that you should share with your trading partners, for them to set you up as a trading partner to send AS2 messages to your organization via the trading station. There you can provide your partner’s email address and directly share these configuration details to your partner
  3. View Station Statistics: where you can view statistics of messages sent and received through the station
  4. Delete Station: when deleting a station, all the messages associated with that station will be permanently deleted

How to create a partner

After configuring a station, you have to add your clients as trading partners. They will act as the receiving endpoints of your station’s outbound messages, and you can receive messages from them as well. To set up a partner, go to ‘Partners’ UI and click ‘New Partner’ button.

AS2 gateway Partner Creation Open image on lightbox

Give the name of your trading partner. Select your partner type; Test or Production. Then provide AS2 identifier, which will uniquely identify the trading partner you are gonna address when exchanging messages. And then you can state a small description of your partner. This will be helpful to easily identify the relevant partner if you are going to create more than one. Then provide the AS2 message receiver URL of the partner and the encryption certificate, which you have already received from them. If your partner has separate certificates for encryption and signing, you can provide the latter as well.

You can set a predefined message subject for your trading partner, which will be used if you haven’t provided a specific subject while sending a message. Then under advanced settings, you can customize AS2 message configurations like encryption, sign algorithms, and the nature of the expected MDN (receipt), specific to the trading partner.

Send AS2 messages

Once you have successfully configured a station and a partner, you are ready to send messages via AS2 Gateway. You can go to the ‘Messages’ UI by the sidebar menu or just click “Send New Message” icon on the bottom right corner in any page. Then in ‘New message’ view select the relevant station and partner from the dropdown list, specify a message subject (optional), attach a document(s) and click ‘Send” button.

AS2 gateway New Message Open image on lightbox

The message will be added to the queue and you will be redirected to the “Queued Messages” view which displays the status of the outbound message. If the message was successfully delivered to the partner, the message will be moved to the ‘Sent’ view where you can find all the necessary details of the message. After 10 automatic retries, if AS2 Gateway is unable to successfully send the queued message out, it will be moved to ‘Failed’ view where you can find its failure reason, along with other message details.

Send AS2 messages via SFTP

When sending/receiving a large number of documents, it’s better to use an integration mechanism like SFTP. And also, if you prefer to integrate internal systems with your trading platform, it’s a perfect choice for you to go with AS2 Gateway SFTP connectivity which you can configure to automate inbound message flow.

To set up SFTP with AS2 Gateway, go to SFTP tab from sidebar menu.

AS2 gateway SFTP Setup Open image on lightbox

Give a valid username and password and click ‘Setup SFTP’ button.

Once the configurations are done, download the private key by clicking on the ‘Export Key’ button. The downloaded file name will be something like id_rsa_username. Navigate to the directory where it is downloaded through the terminal and execute below command (for Linux and macOS) replacing {private_key_file} with your private key file name to set correct permissions to the file.

chmod 400 {private_key_file}

Then, to login to the AS2 Gateway SFTP server, run below command; replacing {private_key_file} and {sftp_username} with your own.

sftp -P 9193 -i {private_key_file} {sftp_username}

Once you have run the above command, it will ask to enter passphrase; which is the password you have given when setting up SFTP. After that, you can successfully connect to the AS2 Gateway’s SFTP server. There you can see a directory named as as2gateway and private and public keys of your SFTP user. In the as2gateway directory, you will find directories being created for each station which are associated with your organization. Each of these directory labels are created under the unique AS2 identifier assigned to the respective station. In each station directory, you will find directories being created for each partner AS2 identifier associated with your organization.

To send documents from AS2 Gateway, transfer your documents via SFTP to the following SFTP path.

If partner type is Production as2gateway/(AS2-Station-ID)/(AS2-Partner-ID)/outbox
If partner type is Test as2gateway/(AS2-Station-ID)/(AS2-Partner-ID)/test/outbox

When sending a multi-document message via SFTP you have to create a folder inside the outbox [as2gateway/(AS2-Station-ID)/(AS2-Partner-ID)/outbox/ or as2gateway/(AS2-Station-ID)/(AS2-Partner-ID)/test/outbox/ ] directory and upload your documents to the newly created folder. 2 minutes after the last file is uploaded, AS2 Gateway will pick up and send all files as one message to the relevant trading partner.

You can download the receiving files via SFTP through the following SFTP path.

If partner type is Production as2gateway/(AS2-Station-ID)/(AS2-Partner-ID)/inbox
If partner type is Test as2gateway/(AS2-Station-ID)/(AS2-Partner-ID)/test/inbox

In inbox directory, all incoming messages will be either separated into subdirectories based on the received timestamp or saved directly in inbox directory with timestamp prefixes – according to the user preference.


AS2 Gateway is an EDI trading platform which was dedicatedly built to reduce underlying complexities of AS2 protocol and build a secure, reliable and faster communication network among B2B enterprises. It provides a variety of customizations when sending/receiving AS2 messages and allows faster integrations with existing internal systems.