Trading Partners API

The Partners API manages trading partner configurations including AS2 identifiers, endpoint URLs, security preferences, and certificate associations. Partners can exist at two levels: tenant-specific partners and account-level master partners that are inherited by tenants.

Table of Contents

Partner Types

Tenant Partners

Standard partners created and managed at the tenant level:

  • Scope: Limited to specific tenant
  • Management: Created via /v1/partners endpoints
  • Use Case: Tenant-specific trading relationships
  • Isolation: Not shared with other tenants

Master Partners (Inherited)

Account-level partners that are automatically inherited by tenants:

  • Scope: Shared across all account tenants
  • Management: Created via /v1/accounts/{account}/partners endpoints (see Master Partners API)
  • Use Case: Common trading partners used by multiple tenants
  • Inheritance: Automatically available to all tenants with optional overrides

Partner Resolution Priority

When a tenant accesses partners, the system returns both types with clear identification:

  1. Tenant-specific partners (created directly for the tenant)
  2. Inherited master partners (shared from account level)
  3. Override capability (tenant settings can override master partner configurations)

List Partners

Retrieve paginated list of trading partners with optional filtering.

GET /v1/partners

Query Parameters

ParameterTypeDefaultConstraintsDescription
searchstringnull1-255 charactersSearch partner names or AS2 IDs
activebooleannulltrue/falseFilter by active status
typeenumnulltenant, inherited, allFilter by partner type
pageinteger1Minimum 1Page number
per_pageinteger201-100Items per page

Note: This endpoint returns both tenant-specific partners and inherited master partners. Use the type parameter to filter results.

Response Schema

Partner Object Fields

FieldTypeNullableDescription
idstringNoPartner identifier
namestringNoHuman-readable partner name
as2_idstringNoAS2 identifier
urlstringNoPartner AS2 endpoint URL
activebooleanNoPartner active status
typeenumNoPartner type (tenant, inherited)
master_partner_idstringYesMaster partner ID (if inherited)
has_overridesbooleanNoWhether tenant has custom overrides
signbooleanNoDigital signing enabled
encryptbooleanNoMessage encryption enabled
compressbooleanNoMessage compression enabled
mdn_modeenumNoMDN delivery mode
sign_algorithmstringYesDigital signing algorithm
encrypt_algorithmstringYesEncryption algorithm
created_atdatetimeNoCreation timestamp
updated_atdatetimeNoLast update timestamp

Success Response (200 OK)

{
  "data": [
    {
      "id": "prt_000001",
      "name": "McKesson Corporation",
      "as2_id": "MCKESSON",
      "url": "https://as2.mckesson.com/receive",
      "active": true,
      "type": "inherited",
      "master_partner_id": "prt_master_001",
      "has_overrides": false,
      "sign": true,
      "encrypt": true,
      "compress": false,
      "mdn_mode": "async",
      "sign_algorithm": "SHA256withRSA",
      "encrypt_algorithm": "AES256_CBC",
      "created_at": "2024-01-01T10:00:00.000000Z",
      "updated_at": "2024-01-15T14:30:00.000000Z"
    },
    {
      "id": "prt_000002",
      "name": "Regional Supplier",
      "as2_id": "REGIONAL-SUPPLIER",
      "url": "https://regional.supplier.com/as2",
      "active": true,
      "type": "tenant",
      "master_partner_id": null,
      "has_overrides": false,
      "sign": true,
      "encrypt": false,
      "compress": true,
      "mdn_mode": "sync",
      "sign_algorithm": "SHA256withRSA",
      "encrypt_algorithm": null,
      "created_at": "2024-01-10T15:20:00.000000Z",
      "updated_at": "2024-01-12T09:45:00.000000Z"
    }
  ],
  "pagination": {
    "current_page": 1,
    "last_page": 2,
    "per_page": 20,
    "total": 25,
    "from": 1,
    "to": 20
  }
}

Create Partner

Create a new tenant-specific trading partner configuration.

POST /v1/partners

Note: This creates a tenant-specific partner. To create master partners shared across tenants, use the Master Partners API endpoints at /v1/accounts/{account}/partners.

Request Parameters

Required Parameters

ParameterTypeConstraintsDescription
namestring1-255 charactersHuman-readable partner name
as2_idstring1-50 characters, no spacesUnique AS2 identifier
urlstringValid HTTPS URLPartner AS2 endpoint

Optional Parameters

ParameterTypeDefaultConstraintsDescription
signbooleanfalse-Enable digital signing
encryptbooleanfalse-Enable message encryption
compressbooleanfalse-Enable message compression
mdn_modeenumasyncsync, async, noneMDN delivery mode
sign_algorithmenumnullValid signing algorithmDigital signing algorithm
encrypt_algorithmenumnullValid encryption algorithmEncryption algorithm

Algorithm Options

Signing Algorithms

AlgorithmKey RequirementsSecurity LevelCompatibility
SHA1withRSA1024+ bit RSALowLegacy systems
SHA256withRSA2048+ bit RSAStandardRecommended
SHA384withRSA2048+ bit RSAEnhancedHigh security
SHA512withRSA2048+ bit RSAHighMaximum security

Encryption Algorithms

AlgorithmKey SizeSecurity LevelPerformance
3DES168-bitLowFast
AES128_CBC128-bitStandardFast
AES192_CBC192-bitEnhancedMedium
AES256_CBC256-bitHighMedium

Request Example

{
  "name": "Acme Corporation",
  "as2_id": "ACME-CORP-AS2",
  "url": "https://acme.example.com/as2",
  "sign": true,
  "encrypt": true,
  "compress": false,
  "mdn_mode": "async",
  "sign_algorithm": "SHA256withRSA",
  "encrypt_algorithm": "AES256_CBC"
}

Response

Success Response (201 Created)

{
  "message": "Partner created successfully",
  "data": {
    "id": "prt_000002",
    "name": "Acme Corporation",
    "as2_id": "ACME-CORP-AS2",
    "url": "https://acme.example.com/as2",
    "active": true,
    "sign": true,
    "encrypt": true,
    "compress": false,
    "mdn_mode": "async",
    "sign_algorithm": "SHA256withRSA",
    "encrypt_algorithm": "AES256_CBC",
    "created_at": "2024-01-15T10:30:00.000000Z",
    "updated_at": "2024-01-15T10:30:00.000000Z"
  }
}

Get Partner Details

Retrieve detailed information about a specific partner including certificates and statistics.

GET /v1/partners/{partner_id}

Path Parameters

ParameterTypeRequiredDescription
partner_idstringYesPartner identifier

Response

Extended Partner Object

Includes additional fields not present in list responses:

FieldTypeDescription
certificatesarrayAssociated certificates
message_statsobjectMessage statistics
last_message_atdatetimeLast message timestamp
connection_statusobjectConnection health information
{
  "data": {
    "id": "prt_000001",
    "name": "Acme Corporation",
    "as2_id": "ACME-CORP-AS2",
    "url": "https://acme.example.com/as2",
    "active": true,
    "sign": true,
    "encrypt": true,
    "compress": false,
    "mdn_mode": "async",
    "sign_algorithm": "SHA256withRSA",
    "encrypt_algorithm": "AES256_CBC",
    "certificates": [
      {
        "id": "cert_000001",
        "name": "Acme Corp Encryption Certificate",
        "type": "partner",
        "usage": "encryption",
        "subject": "CN=Acme Corp AS2, O=Acme Corporation, C=US",
        "active": true,
        "expires_at": "2025-01-01T00:00:00.000000Z",
        "created_at": "2024-01-01T10:00:00.000000Z"
      }
    ],
    "message_stats": {
      "total_sent": 1250,
      "total_received": 890,
      "success_rate": 99.2,
      "last_message_at": "2024-01-15T10:00:00.000000Z"
    },
    "connection_status": {
      "last_test": "2024-01-15T09:00:00.000000Z",
      "last_test_result": "success",
      "response_time_ms": 245
    },
    "created_at": "2024-01-01T10:00:00.000000Z",
    "updated_at": "2024-01-15T14:30:00.000000Z"
  }
}

Update Partner

Modify existing partner configuration.

PATCH /v1/partners/{partner_id}

Path Parameters

ParameterTypeRequiredDescription
partner_idstringYesPartner identifier

Request Parameters

All parameters are optional. Only provided fields will be updated.

ParameterTypeConstraintsDescription
namestring1-255 charactersPartner name
urlstringValid HTTPS URLAS2 endpoint URL
signboolean-Digital signing preference
encryptboolean-Encryption preference
compressboolean-Compression preference
mdn_modeenumsync, async, noneMDN delivery mode
sign_algorithmenumValid algorithmSigning algorithm
encrypt_algorithmenumValid algorithmEncryption algorithm

Response

Returns updated partner object with same schema as create response.

Delete Partner

Permanently remove a trading partner and all associated data.

DELETE /v1/partners/{partner_id}

Path Parameters

ParameterTypeRequiredDescription
partner_idstringYesPartner identifier

Response

Success Response (200 OK)

{
  "message": "Partner deleted successfully",
  "data": {
    "id": "prt_000001",
    "deleted_at": "2024-01-15T10:30:00.000000Z"
  }
}

Deletion Impact

ResourceAction
Partner recordPermanently deleted
Partner certificatesMoved to inactive status
Message historyRetained for audit purposes
Active messagesProcessing continues
Future messagesRejected with PARTNER_NOT_FOUND error

Test Partner Connection

Validate partner configuration and test connectivity.

POST /v1/partners/{partner_id}/test

Request Parameters

ParameterTypeRequiredDefaultDescription
test_typeenumYes-Type of test to perform

Test Types

TypeDescriptionValidation
pingBasic connectivity testDNS resolution, TCP connection, SSL handshake
mdnMDN response testMDN endpoint validation and response
fullComplete AS2 handshakeFull AS2 protocol validation

Response

Success Response (200 OK)

{
  "success": true,
  "message": "Partner connection test successful",
  "data": {
    "test_type": "full",
    "partner": {
      "id": "prt_000001",
      "name": "Acme Corporation",
      "as2_id": "ACME-CORP-AS2",
      "url": "https://acme.example.com/as2"
    },
    "results": {
      "connectivity": "success",
      "ssl_validation": "success",
      "certificate_validation": "success",
      "as2_protocol": "success",
      "response_time_ms": 245
    },
    "timeline": [
      {
        "step": "DNS resolution",
        "status": "success",
        "duration_ms": 12,
        "details": "Resolved acme.example.com to 203.0.113.10"
      },
      {
        "step": "TCP connection",
        "status": "success",
        "duration_ms": 89,
        "details": "Connected to 203.0.113.10:443"
      },
      {
        "step": "SSL handshake",
        "status": "success",
        "duration_ms": 144,
        "details": "TLS 1.3 connection established"
      }
    ],
    "tested_at": "2024-01-15T10:30:00.000000Z"
  }
}

Master Partner Inheritance

Understanding Partner Inheritance

When tenants access partners via /v1/partners, they receive:

  1. Tenant-specific partners - Partners created directly for the tenant
  2. Inherited master partners - Account-level partners automatically shared

Inherited Partner Behavior

Automatic Inheritance

  • All master partners are automatically visible to tenants
  • No explicit inheritance step required
  • Master partner changes propagate to all tenants immediately

Configuration Override

Tenants can override master partner settings for their specific needs:

PATCH /v1/partners/{inherited_partner_id}

Request Example:

{
  "url": "https://tenant-specific.endpoint.com/as2",
  "mdn_mode": "sync"
}

Response:

{
  "message": "Partner configuration overridden successfully",
  "data": {
    "id": "prt_000001",
    "name": "McKesson Corporation",
    "type": "inherited",
    "master_partner_id": "prt_master_001",
    "has_overrides": true,
    "url": "https://tenant-specific.endpoint.com/as2",
    "mdn_mode": "sync",
    "override_settings": {
      "url": "https://tenant-specific.endpoint.com/as2",
      "mdn_mode": "sync"
    }
  }
}

Override Management

View Override Settings:

GET /v1/partners/{inherited_partner_id}/overrides

Reset to Master Configuration:

DELETE /v1/partners/{inherited_partner_id}/overrides

Master vs Tenant Partner Comparison

FeatureMaster PartnersTenant Partners
ScopeAccount-wideTenant-specific
SharingInherited by all tenantsIsolated to tenant
ManagementAccount adminsTenant users
CertificatesShared certificatesTenant certificates
OverridesTenant can customizeN/A
Cost EfficiencyHigh (shared costs)Standard

Best Practices

  1. Use Master Partners for Common Relationships
    • Partners used by multiple tenants
    • Standard industry partners (McKesson, Cardinal Health, etc.)
    • Corporate trading partners
  2. Use Tenant Partners for Specialized Relationships
    • Tenant-specific suppliers
    • Regional partners
    • Testing/development partners
  3. Override Strategically
    • Only override when necessary
    • Document override reasons
    • Review overrides periodically

Partner Certificate Management

List Partner Certificates

GET /v1/partners/{partner_id}/certificates

Upload Partner Certificate

POST /v1/partners/{partner_id}/certificates

Request Parameters (multipart/form-data)

ParameterTypeRequiredDescription
namestringYesCertificate name
usageenumYesencryption, signing, both
certificatefileYesPEM-formatted certificate file

Certificate Usage Types

UsagePurposeKey TypeDescription
encryptionEncrypt outbound messagesPublic keyPartner's public key for encryption
signingVerify inbound signaturesPublic keyPartner's public key for verification
bothEncryption and signingPublic keySingle certificate for both operations

Partner Configuration Schema

Complete Configuration Object

{
  "id": "prt_000001",
  "name": "Acme Corporation",
  "as2_id": "ACME-CORP-AS2",
  "url": "https://acme.example.com/as2",
  "active": true,
  "security": {
    "sign": true,
    "encrypt": true,
    "compress": false,
    "sign_algorithm": "SHA256withRSA",
    "encrypt_algorithm": "AES256_CBC"
  },
  "mdn": {
    "mode": "async",
    "url": "https://acme.example.com/as2/mdn",
    "signed": true,
    "algorithm": "SHA256withRSA"
  },
  "connection": {
    "timeout_seconds": 60,
    "retry_attempts": 3,
    "retry_interval_seconds": 300
  },
  "certificates": [
    {
      "id": "cert_000001",
      "usage": "encryption",
      "active": true,
      "expires_at": "2025-01-01T00:00:00.000000Z"
    }
  ],
  "statistics": {
    "messages_sent": 1250,
    "messages_received": 890,
    "success_rate": 99.2,
    "last_activity": "2024-01-15T10:00:00.000000Z"
  },
  "created_at": "2024-01-01T10:00:00.000000Z",
  "updated_at": "2024-01-15T14:30:00.000000Z"
}

Validation Rules

AS2 ID Requirements

RuleSpecification
Length1-50 characters
CharactersAlphanumeric, hyphens, underscores only
CaseCase-sensitive
UniquenessMust be unique within tenant
FormatNo spaces or special characters

Valid AS2 ID Examples

  • ACME-CORP-AS2
  • SUPPLIER_001
  • PARTNER-PROD-01

Invalid AS2 ID Examples

  • ACME CORP (contains space)
  • PARTNER@PROD (contains special character)
  • partner-001 (if case-sensitive partner expects uppercase)

URL Requirements

RuleSpecification
ProtocolHTTPS only
FormatValid URL format
AccessibilityMust be publicly accessible
PortStandard HTTPS port (443) or custom
PathMust accept POST requests

Error Codes

Partner-Specific Errors

Error CodeHTTP StatusDescriptionResolution
PARTNER_NOT_FOUND404Partner does not existVerify partner ID
DUPLICATE_AS2_ID422AS2 ID already existsUse unique AS2 ID
INVALID_AS2_ID_FORMAT422AS2 ID contains invalid charactersUse alphanumeric and hyphens only
INVALID_ENDPOINT_URL422Partner URL is not valid HTTPSProvide valid HTTPS URL
PARTNER_LIMIT_EXCEEDED402Partner limit for plan exceededUpgrade plan or remove unused partners
UNSUPPORTED_ALGORITHM422Algorithm not supportedUse supported algorithm
CERTIFICATE_REQUIRED400Certificate required for operationUpload required certificate

Partner Validation Error Example

{
  "message": "Validation failed",
  "errors": {
    "as2_id": [
      "The AS2 ID field is required",
      "The AS2 ID must not contain spaces"
    ],
    "url": [
      "The URL must be a valid HTTPS endpoint"
    ],
    "encrypt_algorithm": [
      "The selected encryption algorithm is invalid"
    ]
  }
}

Partner Testing

Connection Test Results

Test Result Schema

FieldTypeDescription
successbooleanOverall test success
test_typeenumType of test performed
resultsobjectDetailed test results
timelinearrayStep-by-step test execution
duration_msintegerTotal test duration
tested_atdatetimeTest execution timestamp

Timeline Step Schema

FieldTypeDescription
stepstringTest step name
statusenumsuccess, warning, failure
duration_msintegerStep execution time
detailsstringStep details or error message

Test Failure Response

{
  "success": false,
  "message": "Partner connection test failed",
  "data": {
    "test_type": "ping",
    "partner": {
      "id": "prt_000001",
      "as2_id": "ACME-CORP-AS2"
    },
    "results": {
      "connectivity": "failed",
      "error": "Connection timeout"
    },
    "timeline": [
      {
        "step": "DNS resolution",
        "status": "success",
        "duration_ms": 15,
        "details": "Resolved to 203.0.113.10"
      },
      {
        "step": "TCP connection",
        "status": "failure",
        "duration_ms": 60000,
        "details": "Connection timeout after 60 seconds"
      }
    ],
    "duration_ms": 60015,
    "tested_at": "2024-01-15T10:30:00.000000Z"
  }
}

Usage Limits

Partner Limits by Plan

PlanMaximum PartnersCertificate StorageTesting Frequency
Free510 certificates10 tests/hour
Starter1025 certificates50 tests/hour
ProfessionalUnlimited100 certificates200 tests/hour
EnterpriseUnlimitedUnlimitedUnlimited

Partner Limit Error

{
  "message": "Partner limit exceeded for current plan",
  "error": {
    "type": "billing_error",
    "code": "PARTNER_LIMIT_EXCEEDED",
    "details": {
      "current_partners": 6,
      "plan_limit": 5,
      "plan": "free",
      "upgrade_url": "https://as2aas.com/dashboard/billing"
    }
  }
}

Integration Examples

Partner Management with Inheritance

// Get all partners (tenant + inherited)
async function getAllPartners(tenantId) {
  const partners = await as2.partners.list();
  
  const result = {
    tenant_partners: partners.data.filter(p => p.type === 'tenant'),
    inherited_partners: partners.data.filter(p => p.type === 'inherited'),
    total: partners.data.length
  };
  
  return result;
}

// Create tenant-specific partner
async function createTenantPartner(partnerData) {
  const partner = await as2.partners.create({
    name: partnerData.name,
    as2_id: partnerData.as2_id,
    url: partnerData.endpoint,
    sign: true,
    encrypt: true,
    sign_algorithm: 'SHA256withRSA',
    encrypt_algorithm: 'AES256_CBC'
  });
  
  // Upload tenant-specific certificates
  if (partnerData.encryptionCertificate) {
    await as2.partners.uploadCertificate(partner.id, {
      name: `${partner.name} Encryption`,
      usage: 'encryption',
      certificate: partnerData.encryptionCertificate
    });
  }
  
  return partner;
}

// Override master partner configuration
async function overrideMasterPartner(partnerId, overrides) {
  const updatedPartner = await as2.partners.update(partnerId, overrides);
  
  console.log(`Master partner ${partnerId} overridden for tenant`);
  console.log('Overrides:', updatedPartner.data.override_settings);
  
  return updatedPartner;
}

Bulk Partner Operations

// Bulk partner management
async function bulkUpdatePartners(updates) {
  const results = [];
  
  for (const update of updates) {
    try {
      const result = await updatePartner(update.partner_id, update.changes);
      results.push({ success: true, partner_id: update.partner_id, data: result });
    } catch (error) {
      results.push({ 
        success: false, 
        partner_id: update.partner_id, 
        error: error.message 
      });
    }
  }
  
  return results;
}