Purchase Order API

EDI 850 JSON Format API Documentation

Version 1.0.0

Base URL: https://api-edi.nationalpublicseating.com/

Overview

The Purchase Order API accepts purchase order data in EDI 850 JSON format via authenticated REST endpoints. Submit your purchase orders and receive immediate confirmation of receipt.

Authentication

All API endpoints (except /auth/token) require JWT authentication.

Authentication Types by Endpoint

Endpoint Auth Type Notes
POST /api/v1/auth/token No Auth Send username/password in body
POST /api/v1/files Bearer Token Use token from auth endpoint
POST /api/v1/files/upload Bearer Token Use token from auth endpoint
GET /health No Auth Public health check

Get Authentication Token

POST /api/v1/auth/token

Authentication: None (this endpoint does not require authentication)

Request Body (JSON):

{
  "username": "your_username",
  "password": "your_password"
}
?? Important: Field names are case-sensitive. Use lowercase "username" and "password", not "Username" or "Password".

Response (200 OK):

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "expiresIn": 3600
}

Example (cURL):

curl -X POST https://api-edi.nationalpublicseating.com/api/v1/auth/token \
  -H "Content-Type: application/json" \
  -d '{
    "username": "your_username",
    "password": "your_password"
  }'

Example (JavaScript):

const response = await fetch('https://api-edi.nationalpublicseating.com/api/v1/auth/token', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    username: 'your_username',
    password: 'your_password'
  })
});

const { token, expiresIn } = await response.json();
Notes:
  • Tokens expire after 1 hour (3600 seconds)
  • Request a new token when the current one expires
  • Store the token securely
  • Field names are case-sensitive: Use "username" and "password" (lowercase)

Submit Purchase Order

Method 1: Submit JSON Data

POST /api/v1/files

Authentication: Bearer Token (required)

Headers:

  • Content-Type: application/json
  • Authorization: Bearer YOUR_TOKEN

Standard Format (Recommended)

{
  "Id": "PO123456",
  "Version": 2020.1,
  "Timestamp": "2024-10-29T12:00:00Z",
  "POHeader": {
    "SoldTo": {
      "PartyId": "1100001001675",
      "Name": "Music Products Center",
      "Address": {
        "Attn": "BatchClient",
        "Address1": "Accounts Payable",
        "City": "Fort Wayne",
        "State": "IN",
        "PostalCode": "46818",
        "Country": "USA",
        "CountryCode": "US"
      }
    },
    "ShipTo": {
      "PartyId": "1200109211324",
      "Name": "Music Products Center AZDC",
      "Address": {
        "Address1": "16801 W Glendale Ave.",
        "City": "Litchfield Park",
        "State": "AZ",
        "PostalCode": "85340",
        "Country": "USA",
        "CountryCode": "US"
      }
    },
    "BuyerOrderId": "PO123456",
    "DateOrdered": "2024-10-29"
  },
  "PODetail": {
    "Items": [
      {
        "POLineNbr": 1,
        "BuyerItemId": "ITEM001",
        "Qty": 10,
        "UCValue": 99.99
      }
    ]
  }
}

Response (200 OK):

{
  "fileId": "550e8400-e29b-41d4-a716-446655440000",
  "status": "received",
  "timestamp": "2024-10-29T12:34:56.789Z"
}

Method 2: Upload JSON File

POST /api/v1/files/upload

Authentication: Bearer Token (required)

Headers:

  • Content-Type: multipart/form-data
  • Authorization: Bearer YOUR_TOKEN

Request:

  • Form field name: file
  • File type: JSON (.json)
  • Max file size: 10MB

Example (cURL):

curl -X POST https://api-edi.nationalpublicseating.com/api/v1/files/upload \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F "file=@purchase-order.json"

Health Check

GET /health

Response (200 OK):

{
  "status": "healthy",
  "timestamp": "2024-10-29T12:34:56.789Z"
}

Error Responses

All error responses follow this format:

{
  "error": "Error Type",
  "message": "Detailed error message",
  "timestamp": "2024-10-29T12:34:56.789Z"
}

HTTP Status Codes

Code Description Common Causes
200 Success Request processed successfully
400 Bad Request Missing fields, invalid JSON, schema validation failure
401 Unauthorized Missing token, invalid token, expired token
404 Not Found Invalid endpoint
500 Server Error File system error, unexpected exception

Rate Limits

Security Notes

  • HTTPS Required: Always use HTTPS in production
  • Token Security: Never share or commit tokens
  • Credentials: Store credentials securely
  • File Size: Files are limited to 10MB
  • Validation: All data is validated before processing