Getting Started

This guide will walk you through the essential steps to begin using AS2aaS for secure B2B messaging. You'll learn how to authenticate with the platform, configure trading partners, and send your first AS2 message.

Prerequisites

Before beginning integration with AS2aaS, ensure you have:

  • An active AS2aaS account with API access
  • Your API credentials from the platform dashboard
  • Basic understanding of REST API concepts
  • Trading partner information (AS2 ID, endpoint URL, certificates)

API Credentials

Obtain your API credentials from the AS2aaS dashboard:

  1. Access the platform dashboard
  2. Navigate to API Management
  3. Generate new API key for your environment
  4. Securely store the API key in your application configuration
Environment Separation
Use test keys (pk_test_) for development and staging environments. Production keys (pk_live_) should only be used in production systems.

Configure Trading Partner

Create your first trading partner to establish a B2B messaging relationship:

curl -X POST https://api.as2aas.com/v1/partners \
  -H "Authorization: Bearer pk_test_your_api_key" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: partner_creation_001" \
  -d '{
    "as2_id": "PARTNER_CORP",
    "name": "Partner Corporation",
    "url": "https://partner.example.com/as2/receive",
    "email": "[email protected]",
    "compression": true,
    "mdn_mode": "sync"
  }'

Response:

{
  "id": "prt_1234567890",
  "as2_id": "PARTNER_CORP", 
  "name": "Partner Corporation",
  "url": "https://partner.example.com/as2/receive",
  "status": "active",
  "compression": true,
  "mdn_mode": "sync",
  "created_at": "2024-01-15T10:30:00Z"
}

Send AS2 Message

Transmit your first AS2 message to the configured trading partner:

curl -X POST https://api.as2aas.com/v1/messages \
  -H "Authorization: Bearer pk_test_your_api_key" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: message_001" \
  -d '{
    "partner_id": "prt_1234567890",
    "subject": "Business Document Transmission",
    "payload": {
      "content": "ISA*00*          *00*          *ZZ*SENDER_ID      *ZZ*PARTNER_CORP   *240115*1030*U*00401*000000001*0*T*>~GS*IN*SENDER_ID*PARTNER_CORP*20240115*1030*1*X*004010~ST*810*0001~BGN*00*DOC001*20240115~N1*ST*Partner Corporation~SE*4*0001~GE*1*1~IEA*1*000000001~",
      "filename": "business_document.edi"
    },
    "content_type": "application/edi-x12"
  }'

Response:

{
  "id": "msg_9876543210",
  "partner_id": "prt_1234567890", 
  "subject": "Business Document Transmission",
  "status": "queued",
  "direction": "outbound",
  "content_type": "application/edi-x12",
  "created_at": "2024-01-15T10:35:00Z"
}

Track Message Status

Monitor message processing and delivery status:

curl -X GET https://api.as2aas.com/v1/messages/msg_9876543210 \
  -H "Authorization: Bearer pk_test_your_api_key"

Response:

{
  "id": "msg_9876543210",
  "partner_id": "prt_1234567890",
  "subject": "Business Document Transmission", 
  "status": "delivered",
  "direction": "outbound",
  "content_type": "application/edi-x12",
  "message_id": "[email protected]",
  "mdn_status": "received",
  "created_at": "2024-01-15T10:35:00Z",
  "updated_at": "2024-01-15T10:35:15Z",
  "delivered_at": "2024-01-15T10:35:15Z"
}

Message Status Progression

AS2 messages progress through the following states:

  1. queued - Message accepted and queued for processing
  2. processing - Message being prepared and transmitted
  3. sent - Message successfully transmitted to partner
  4. delivered - MDN receipt confirmation received
  5. failed - Transmission failed with error details

Configure Event Notifications

Set up webhook endpoints to receive real-time event notifications:

curl -X POST https://api.as2aas.com/v1/webhook-endpoints \
  -H "Authorization: Bearer pk_test_your_api_key" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: webhook_001" \
  -d '{
    "url": "https://your-application.com/webhooks/as2",
    "events": [
      "message.sent",
      "message.delivered", 
      "message.failed"
    ],
    "description": "AS2 message status notifications"
  }'

Common Integration Patterns

EDI Document Processing

# Send EDI 810 (Invoice) document
curl -X POST https://api.as2aas.com/v1/messages \
  -H "Authorization: Bearer pk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: invoice_$(date +%s)" \
  -d '{
    "partner_id": "prt_trading_partner",
    "subject": "Invoice Document",
    "payload": {
      "content": "ISA*00*...*810*...",
      "filename": "invoice_001.edi"
    },
    "content_type": "application/edi-x12"
  }'

XML Document Exchange

# Send XML business document
curl -X POST https://api.as2aas.com/v1/messages \
  -H "Authorization: Bearer pk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: xml_doc_$(date +%s)" \
  -d '{
    "partner_id": "prt_xml_partner",
    "subject": "Purchase Order Document",
    "payload": {
      "content": "<?xml version=\"1.0\"?><PurchaseOrder><OrderID>PO-001</OrderID></PurchaseOrder>",
      "filename": "purchase_order.xml"
    },
    "content_type": "application/xml"
  }'

Healthcare/Pharmaceutical Integration

# Send EPCIS document for pharmaceutical compliance
curl -X POST https://api.as2aas.com/v1/messages \
  -H "Authorization: Bearer pk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: epcis_$(date +%s)" \
  -d '{
    "partner_id": "prt_pharma_partner",
    "subject": "DSCSA Compliance Document",
    "payload": {
      "content": "<?xml version=\"1.0\"?><epcis:EPCISDocument>...</epcis:EPCISDocument>",
      "filename": "dscsa_compliance.xml"
    },
    "content_type": "application/xml",
    "headers": {
      "DSCSA-Version": "3.0",
      "Document-Type": "Verification"
    }
  }'

Error Handling

Implement proper error handling for robust integrations:

async function sendAS2Message(partnerID, payload) {
  try {
    const response = await fetch('https://api.as2aas.com/v1/messages', {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${process.env.AS2AAS_API_KEY}`,
        'Content-Type': 'application/json',
        'Idempotency-Key': `msg_${Date.now()}`
      },
      body: JSON.stringify({
        partner_id: partnerID,
        payload: payload,
        content_type: 'application/edi-x12'
      })
    });

    if (!response.ok) {
      const error = await response.json();
      throw new Error(`AS2 API Error: ${error.error.message}`);
    }

    return await response.json();
  } catch (error) {
    console.error('Failed to send AS2 message:', error);
    throw error;
  }
}

Next Steps

Continue your integration by exploring additional platform capabilities: