Skip to main content

Create Machine Client

Creates a machine client — OAuth2 client credentials for server-to-server (S2S) integrations. The client secret is returned only once and must be stored securely.
POST /v1/organizations/:orgId/machine-clients

Path Parameters

ParameterTypeRequiredDescription
orgIdstringRequiredOrganization ID (prefix: org_)

Request Body

ParameterTypeRequiredDescription
namestringRequiredHuman-readable identifier (e.g., epic-ehr-integration)
dockIdstringOptionalRestrict client to specific dock (recommended)
scopesarrayOptionalPermission scopes (defaults to all available)
partyIdstringOptionalLink to party record for audit trails

Available Scopes

ScopeDescriptionUse Case
artifacts:writeCreate/upload artifactsEHR integration pushing medical records
artifacts:readList and retrieve artifactsPartner system downloading documents
policies:readRead access policiesCompliance system auditing rules
recipients:readRead recipient catalogCRM integration syncing contacts
audit:readRead audit logsSIEM integration for security monitoring

Example Request

curl -X POST https://api.docyard.io/v1/organizations/org_01HQ3K.../machine-clients \
  -H "Authorization: Bearer dk_live_a1b2c3d4..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "epic-ehr-integration",
    "dockId": "dock_metro_general",
    "scopes": ["artifacts:write", "artifacts:read"],
    "partyId": "pty_metro_health_system"
  }'

Response

CRITICAL: The clientSecret is displayed only once upon creation. Store it immediately in a secrets manager. If lost, you must rotate the secret.
{
  "id": "mc_01HQ3K9B2...",
  "clientId": "dyc_epic_prod_a1b2c3d4",
  "clientSecret": "dys_live_efghijklmnop...",
  "name": "epic-ehr-integration",
  "scopes": ["artifacts:write", "artifacts:read"],
  "dockId": "dock_metro_general",
  "organizationId": "org_01HQ3K...",
  "partyId": "pty_metro_health_system",
  "isActive": true,
  "createdAt": "2024-03-01T12:00:00.000Z"
}

Response Fields

FieldTypeDescription
idstringMachine client identifier (prefix: mc_)
clientIdstringOAuth2 client identifier (prefix: dyc_)
clientSecretstringOAuth2 client secret (prefix: dys_) — shown only once
namestringHuman-readable identifier
scopesarrayGranted permission scopes
dockIdstringRestricted dock (null if organization-wide)
organizationIdstringParent organization
partyIdstringLinked party for audit trails
isActivebooleanWhether client is active
createdAtstringISO 8601 timestamp

Token Prefix Reference

PrefixTypeExample
dyc_Machine Client IDdyc_epic_prod_a1b2c3d4
dys_Machine Client Secretdys_live_efghijklmnop...
dyt_Machine Access Tokendyt_live_qrstuvwx...

Security Best Practices

Dock Scoping: Always specify dockId unless the client needs organization-wide access. This limits the blast radius if credentials are compromised. Scope Selection: Request only the scopes you need:
  • Ingestion-only: ["artifacts:write"]
  • Retrieval-only: ["artifacts:read"]
  • Full access: ["artifacts:write", "artifacts:read"]
Secret Storage: Store in a secrets manager (AWS Secrets Manager, HashiCorp Vault, Azure Key Vault), never in source code or environment variables in plain text.

Error Handling

StatusCondition
400Invalid scopes or missing required fields
401Missing or invalid API key
404Organization, dock, or party not found

Next Steps

After creating a machine client:
  1. Store the secret securely in a secrets manager
  2. Issue an access token via OAuth2 token endpoint
  3. Make API calls using the bearer token
  4. Implement token refresh logic in your application