Wove Sources API

Rate sheet source management - upload, process, and query status

OpenAPI Specification

wove-sources-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Wove External Authentication Sources API
  version: 1.0.0
  description: "# Wove External API Documentation\n\nThe Wove External API allows you to programmatically access document processing, shipment management, and validation capabilities.\n\n## Features\n\n- **OAuth 2.0 Authentication**: Secure client credentials flow\n- **Rate Limiting**: Configurable per-client rate limits\n- **Document Processing**: Upload, validate, and merge shipping documents\n- **Shipment Management**: Create and manage shipment records with validation and merge operations\n- **Webhooks**: Get notified of document processing events (extraction, validation, merge)\n- **Comprehensive Error Handling**: Detailed error responses with troubleshooting information\n\n## Getting Started\n\n1. **Create OAuth Client**: Contact your account manager to create OAuth credentials\n2. **Get Access Token**: Use client credentials flow to obtain bearer token\n3. **Make API Calls**: Include bearer token in Authorization header\n4. **Handle Rate Limits**: Monitor rate limit headers in responses\n\n## Authentication\n\nAll API endpoints require OAuth 2.0 authentication using the client credentials flow.\n\n### Getting an Access Token\n\n```bash\ncurl -X POST https://api.wove.com/api/v1/external/auth/token \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"grant_type\": \"client_credentials\",\n    \"client_id\": \"your_client_id\",\n    \"client_secret\": \"your_client_secret\"\n  }'\n```\n\n### Using the Access Token\n\nInclude the access token in the Authorization header:\n\n```bash\ncurl -H \"Authorization: Bearer your_access_token\" \\\n  https://api.wove.com/api/v1/external/shipments\n```\n\n## Rate Limiting\n\nAll endpoints are subject to rate limiting based on your OAuth client configuration:\n\n- **Per-minute limit**: Default 60 requests/minute\n- **Daily limit**: Default 10,000 requests/day\n\nRate limit information is included in response headers:\n- `X-RateLimit-Limit-Minute`: Your per-minute limit\n- `X-RateLimit-Remaining-Minute`: Remaining requests this minute\n- `X-RateLimit-Reset-Minute`: When the minute window resets\n- `X-RateLimit-Limit-Day`: Your daily limit\n- `X-RateLimit-Remaining-Day`: Remaining requests today\n- `X-RateLimit-Reset-Day`: When the daily window resets\n\n## Webhook Security\n\nAll webhook payloads are signed using HMAC-SHA256 for verification:\n\n```javascript\n// Verify webhook signature\nconst crypto = require('crypto');\nconst signature = request.headers['x-wove-signature'];\nconst payload = JSON.stringify(request.body);\nconst expectedSignature = crypto\n  .createHmac('sha256', your_webhook_secret)\n  .update(payload)\n  .digest('hex');\n\nconst isValid = crypto.timingSafeEqual(\n  Buffer.from(signature),\n  Buffer.from(expectedSignature)\n);\n```\n\nHeaders included with every webhook:\n- `X-Wove-Signature`: HMAC-SHA256 signature of the payload\n- `X-Wove-Event`: Event type (e.g., \"extraction.completed\")\n- `X-Wove-Timestamp`: ISO timestamp when the webhook was sent\n\n## Error Handling\n\nAll errors follow a consistent format:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"VALIDATION_ERROR\",\n    \"message\": \"One or more documents not found or access denied\",\n    \"details\": {\n      \"field\": \"documentIds\",\n      \"value\": [\"invalid_id\"]\n    }\n  }\n}\n```\n\n### Error Codes\n\n- `VALIDATION_ERROR` - Invalid request parameters or data validation failure\n- `AUTHENTICATION_ERROR` - Invalid or expired credentials\n- `AUTHORIZATION_ERROR` - Insufficient permissions for the requested operation\n- `NOT_FOUND` - Requested resource not found\n- `RATE_LIMIT_ERROR` - Too many requests, rate limit exceeded\n- `INTERNAL_ERROR` - Internal server error\n\nSee the common error responses in the components section for detailed examples.\n"
  contact:
    name: Wove API Support
    email: api-support@wove.com
    url: https://docs.wove.com
  license:
    name: Proprietary
    url: https://wove.com/terms
servers:
- url: https://api.wove.com
  description: Production server
- url: https://staging-api.wove.com
  description: Staging server
- url: http://localhost:4000
  description: Development server
security:
- bearerAuth: []
tags:
- name: Sources
  description: Rate sheet source management - upload, process, and query status
paths:
  /api/v1/external/sources/upload:
    post:
      tags:
      - Sources
      summary: Get presigned URL for source upload
      description: 'Creates a new source record and returns a presigned URL for uploading a rate sheet file.


        **Workflow**:

        1. Call this endpoint with file metadata

        2. Upload the file directly to the returned presigned URL using PUT

        3. Call POST /sources/{sourceId}/process to start processing


        **Supported file types**: Excel (.xlsx, .xls), CSV, PDF


        **File size limit**: 50MB

        '
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSourceUploadRequest'
            example:
              filename: carrier_rates_2024.xlsx
              contentType: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
              sourceType: contract
              carrierId: '123456789'
              effectiveDate: '2024-01-01'
              expiryDate: '2024-12-31'
              description: Q1 2024 contract rates from carrier
      responses:
        '201':
          description: Source created successfully with upload URL
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: '#/components/schemas/CreateSourceUploadResponse'
              example:
                success: true
                data:
                  sourceId: '1234567890123456789'
                  uploadUrl: https://s3.amazonaws.com/bucket/path?signature=...
                  expiresAt: '2024-01-15T12:30:00.000Z'
        '400':
          description: Bad request - invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Insufficient permissions - requires sources:write scope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /api/v1/external/sources/{sourceId}/process:
    post:
      tags:
      - Sources
      summary: Start processing an uploaded source
      description: 'Initiates processing of a source file after it has been uploaded to the presigned URL.


        The source will be queued for processing and its status will transition through:

        - `pending` → `processing` → `complete` or `failed`


        Use GET /sources/{sourceId} to monitor processing status.

        Configure webhooks to receive notifications when processing completes.

        '
      security:
      - bearerAuth: []
      parameters:
      - name: sourceId
        in: path
        required: true
        schema:
          type: string
        description: The source ID returned from the upload endpoint
        example: '1234567890123456789'
      responses:
        '200':
          description: Processing started successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: '#/components/schemas/ProcessSourceResponse'
              example:
                success: true
                data:
                  sourceId: '1234567890123456789'
                  status: pending
                  message: Source queued for processing
        '400':
          description: Source not ready for processing (not uploaded yet)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Source not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /api/v1/external/sources:
    get:
      tags:
      - Sources
      summary: List all sources
      description: 'Returns a paginated list of all rate sheet sources for your organization.


        Sources can be filtered by status and sorted by various fields.

        '
      security:
      - bearerAuth: []
      parameters:
      - name: status
        in: query
        schema:
          type: string
          enum:
          - awaiting_upload
          - pending
          - processing
          - complete
          - failed
        description: Filter by processing status
      - name: carrierId
        in: query
        schema:
          type: string
        description: Filter by carrier ID
      - name: limit
        in: query
        schema:
          type: integer
          default: 50
          maximum: 100
        description: Number of results to return
      - name: offset
        in: query
        schema:
          type: integer
          default: 0
        description: Number of results to skip
      responses:
        '200':
          description: Sources retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      sources:
                        type: array
                        items:
                          $ref: '#/components/schemas/ExternalSourceSummary'
                      total:
                        type: integer
                        description: Total number of sources matching the filter
              example:
                success: true
                data:
                  sources:
                  - id: '1234567890123456789'
                    filename: carrier_rates_2024.xlsx
                    status: complete
                    sourceType: contract
                    carrierId: '123456789'
                    carrierName: Maersk
                    rateCount: 1250
                    effectiveDate: '2024-01-01'
                    expiryDate: '2024-12-31'
                    createdAt: '2024-01-15T10:00:00.000Z'
                    processedAt: '2024-01-15T10:05:00.000Z'
                  total: 1
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /api/v1/external/sources/{sourceId}:
    get:
      tags:
      - Sources
      summary: Get source details
      description: 'Returns detailed information about a specific source, including processing status and any errors.

        '
      security:
      - bearerAuth: []
      parameters:
      - name: sourceId
        in: path
        required: true
        schema:
          type: string
        description: The source ID
        example: '1234567890123456789'
      responses:
        '200':
          description: Source details retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: '#/components/schemas/ExternalSourceDetail'
              example:
                success: true
                data:
                  id: '1234567890123456789'
                  filename: carrier_rates_2024.xlsx
                  status: complete
                  sourceType: contract
                  carrierId: '123456789'
                  carrierName: Maersk
                  rateCount: 1250
                  effectiveDate: '2024-01-01'
                  expiryDate: '2024-12-31'
                  description: Q1 2024 contract rates
                  createdAt: '2024-01-15T10:00:00.000Z'
                  processedAt: '2024-01-15T10:05:00.000Z'
                  error: null
        '404':
          description: Source not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    CreateSourceUploadRequest:
      type: object
      properties:
        filename:
          type: string
          description: The filename of the rate sheet to upload
          example: carrier_rates_2024.xlsx
        contentType:
          type: string
          description: MIME type of the file
          example: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
        sourceType:
          type: string
          enum:
          - contract
          - spot
          - tariff
          description: Type of rate sheet
        carrierId:
          type: string
          description: Optional carrier ID to associate with this source
        effectiveDate:
          type: string
          format: date
          description: Date when rates become effective
        expiryDate:
          type: string
          format: date
          description: Date when rates expire
        description:
          type: string
          description: Optional description of the source
      required:
      - filename
    ExternalSourceDetail:
      type: object
      properties:
        id:
          type: string
        filename:
          type: string
        status:
          type: string
          enum:
          - awaiting_upload
          - pending
          - processing
          - complete
          - failed
        sourceType:
          type: string
          enum:
          - contract
          - spot
          - tariff
        carrierId:
          type: string
        carrierName:
          type: string
        rateCount:
          type: integer
        effectiveDate:
          type: string
          format: date
        expiryDate:
          type: string
          format: date
        description:
          type: string
        createdAt:
          type: string
          format: date-time
        processedAt:
          type: string
          format: date-time
        error:
          type: string
          nullable: true
          description: Error message if processing failed
    ProcessSourceResponse:
      type: object
      properties:
        sourceId:
          type: string
          description: The source ID
        status:
          type: string
          enum:
          - pending
          - processing
          description: Current processing status
        message:
          type: string
          description: Status message
      required:
      - sourceId
      - status
    CreateSourceUploadResponse:
      type: object
      properties:
        sourceId:
          type: string
          description: Unique identifier for the created source
        uploadUrl:
          type: string
          description: Presigned URL for uploading the file (expires in 15 minutes)
        expiresAt:
          type: string
          format: date-time
          description: When the upload URL expires
      required:
      - sourceId
      - uploadUrl
      - expiresAt
    ExternalSourceSummary:
      type: object
      properties:
        id:
          type: string
          description: Source ID
        filename:
          type: string
          description: Original filename
        status:
          type: string
          enum:
          - awaiting_upload
          - pending
          - processing
          - complete
          - failed
          description: Processing status
        sourceType:
          type: string
          enum:
          - contract
          - spot
          - tariff
        carrierId:
          type: string
        carrierName:
          type: string
        rateCount:
          type: integer
          description: Number of rates extracted from this source
        effectiveDate:
          type: string
          format: date
        expiryDate:
          type: string
          format: date
        createdAt:
          type: string
          format: date-time
        processedAt:
          type: string
          format: date-time
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          properties:
            code:
              type: string
              example: VALIDATION_ERROR
            message:
              type: string
              example: Invalid input parameters
            details:
              type: object
              description: Additional error context
      required:
      - success
      - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: OAuth 2.0 Bearer token obtained from /auth/token endpoint