Enviar Mensajes AS2

Send AS2 messages to your trading partners with support for digital signatures, encryption, and compression.

POST /api/v1/messages/send

Send an AS2 message to a trading partner. The router supports both single-file and multi-file sending.

Request Body
CampoTipoRequeridoDescripción
partnerintegerTarget partner ID
subjectstringMessage subject
uploadsarrayFile list for multi-file sending
file_namestringFile name when sending a single document
file_contentstringBase64 content for single-file sending
encryptbooleanEncrypt the message
signbooleanSign the message
compressbooleanCompress payloads with zlib
stationintegerOptional context used for multi-file sending

Legacy aliases also accepted: socio, asunto, comprimir.

Upload Object
CampoTipoDescripción
filenamestringFile name
contentstringBase64 content
Example - Single file
import base64

with open("document.txt", "rb") as f:
    content_b64 = base64.b64encode(f.read()).decode()

response = requests.post(
    f"{BASE_URL}/messages/send",
    headers=headers,
    json={
        "station": 54,
        "partner": 94,
        "subject": "Invoice #001",
        "file_name": "invoice.txt",
        "file_content": content_b64,
        "encrypt": False,
        "sign": False
    }
)
curl
curl -X POST "https://free.as2expert.com/api/v1/messages/send"   -H "Authorization: Bearer $API_TOKEN"   -H "Content-Type: application/json"   -d '{
    "station": 54,
    "partner": 94,
    "subject": "Invoice #001",
    "file_name": "invoice.txt",
    "file_content": "BASE64_FILE_CONTENT_HERE",
    "encrypt": false,
    "sign": false
  }'
Example - Multiple files
files = ["doc1.txt", "doc2.txt"]
uploads = []

for f in files:
    with open(f, "rb") as fp:
        uploads.append({
            "filename": f,
            "content": base64.b64encode(fp.read()).decode()
        })

response = requests.post(
    f"{BASE_URL}/messages/send",
    headers=headers,
    json={
        "station": 54,
        "partner": 94,
        "subject": "Batch of documents",
        "uploads": uploads,
        "sign": True
    }
)
JavaScript
const response = await fetch("https://free.as2expert.com/api/v1/messages/send", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    station: 54,
    partner: 94,
    subject: "Batch of documents",
    uploads,
    sign: true
  })
});
Response
{
  "status": "success",
  "msg": "Message sent",
  "data": {
    "id": 261326,
    "message_id": 261326,
    "message_as2_id": "as2experts.com_7c8c0793-b738-4195-b9e9-3e8a3a7b6bdc",
    "station": 54,
    "files_count": 1
  }
}

Processing order

  1. Compression - If compress=true, payloads are compressed with zlib
  2. Signature - If sign=true, the message is signed with the station certificate
  3. Encryption - If encrypt=true, the message is encrypted with the partner certificate
  4. AS2 delivery - The payload is sent to the partner endpoint over HTTP POST