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
| Campo | Tipo | Requerido | Descripción |
|---|---|---|---|
| partner | integer | Target partner ID | |
| subject | string | Message subject | |
| uploads | array | File list for multi-file sending | |
| file_name | string | File name when sending a single document | |
| file_content | string | Base64 content for single-file sending | |
| encrypt | boolean | Encrypt the message | |
| sign | boolean | Sign the message | |
| compress | boolean | Compress payloads with zlib | |
| station | integer | Optional context used for multi-file sending |
Legacy aliases also accepted: socio, asunto, comprimir.
Upload Object
| Campo | Tipo | Descripción |
|---|---|---|
| filename | string | File name |
| content | string | Base64 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
- Compression - If compress=true, payloads are compressed with zlib
- Signature - If sign=true, the message is signed with the station certificate
- Encryption - If encrypt=true, the message is encrypted with the partner certificate
- AS2 delivery - The payload is sent to the partner endpoint over HTTP POST