API referencePlatform APIEndpoint reference
GUIDE & REFERENCE

/api/v1/services/[id]/bind (management)

Source-derived management endpoint contract, authentication, request validation, responses, and errors.

This is the management service route. Its origin and authentication are described in Platform API overview and Authentication. A path shared by another service is a different endpoint.

PropertyContract
MethodsPOST
Path/api/v1/services/[id]/bind
Path parametersid
Query parameters read in routeNone read directly; schema validation below may define additional fields
Headers read in routeNo additional direct header reads; authentication helpers may read credentials

Authentication and access

Management auth context: validated x-api-key or configured session authentication; trusted gateway integration may select its auth pipeline. Organization/tenant checks are separate.

Request and response definitions

The following named definitions are imported or declared by this route. Optional markers, defaults, bounds, and enum values are shown exactly as implemented. A response type is a source contract, not an example populated with real account data.

ServiceBindingRequest

ServiceBindingRequest = z.object({
  target_service_id: z.string(),
  binding_config: z.record(z.unknown()).optional(),
})

Source: minds-ui/apps/api-service/types/service.ts:222.

ServiceBindingRequest

export type ServiceBindingRequest = z.infer<typeof ServiceBindingRequest>

Source: minds-ui/apps/api-service/types/service.ts:227.

ServiceBindingResponse

ServiceBindingResponse = z.object({
  source_service_id: z.string(),
  target_service_id: z.string(),
  binding_status: z.enum(['bound', 'failed']),
  endpoint: z.string().url().optional(),
  binding_metadata: z.record(z.unknown()).optional(),
})

Source: minds-ui/apps/api-service/types/service.ts:233.

ServiceBindingResponse

export type ServiceBindingResponse = z.infer<typeof ServiceBindingResponse>

Source: minds-ui/apps/api-service/types/service.ts:241.

Method behavior

The handler excerpt preserves field validation, response envelopes, cookie changes, and exception branches. Values returned by service helpers retain their named response type above; for passthrough routes, the upstream response is authoritative.

POST

export async function POST(
  request: NextRequest,
  { params }: { params: Promise<{ id: string }> },
) {
  const requestId = generateRequestId()
  let rateLimitInfo: RateLimitMetadata | undefined

  try {
    const authContext = await resolveAuthContext(request)
    const { id } = await params
    const body = await validateBody(request, ServiceBindingRequest)

    const evaluation = await enforceRateLimit({
      context: authContext,
    })

    rateLimitInfo = {
      ...evaluation.metadata,
      retryAfter: evaluation.retryAfter,
    }

    if (evaluation.blocked) {
      throw new RateLimitExceededError(evaluation.retryAfter ?? 60)
    }

    const result = await bindService(authContext, id, body)

    const response = apiSuccess<ServiceBindingResponse>(result)
    return withRequestMetadata(response, requestId, rateLimitInfo)
  } catch (error) {
    if (error instanceof ApiError) {
      const response = apiError(error, requestId)
      return withRequestMetadata(response, requestId, rateLimitInfo)
    }
    console.error('Failed to bind service:', error)
    const response = apiError(
      new ApiError(500, 'INTERNAL_ERROR', 'Failed to bind service'),
      requestId,
    )
    return withRequestMetadata(response, requestId, rateLimitInfo)
  }
}

Source: minds-ui/apps/api-service/app/api/v1/services/[id]/bind/route.ts:23.

Response and error branches

Literal HTTP statuses in the route: 500. Shared management error classes are defined in Errors and responses.

new RateLimitExceededError(evaluation.retryAfter ?? 60)

Source: minds-ui/apps/api-service/app/api/v1/services/[id]/bind/route.ts:45.

apiSuccess<ServiceBindingResponse>(result)

Source: minds-ui/apps/api-service/app/api/v1/services/[id]/bind/route.ts:50.

apiError(error, requestId)

Source: minds-ui/apps/api-service/app/api/v1/services/[id]/bind/route.ts:54.

apiError(
      new ApiError(500, 'INTERNAL_ERROR', 'Failed to bind service'),
      requestId,
    )

Source: minds-ui/apps/api-service/app/api/v1/services/[id]/bind/route.ts:58.

new ApiError(500, 'INTERNAL_ERROR', 'Failed to bind service')

Source: minds-ui/apps/api-service/app/api/v1/services/[id]/bind/route.ts:59.

Service dependencies

  • minds-ui/apps/api-service/lib/api-response.ts
  • minds-ui/apps/api-service/lib/validation.ts
  • minds-ui/apps/api-service/types/service.ts
  • minds-ui/apps/api-service/types/errors.ts
  • minds-ui/apps/api-service/lib/services/auth-context.ts
  • minds-ui/apps/api-service/lib/services/service-manager.ts
  • minds-ui/apps/api-service/lib/services/rate-limit.ts

Evidence

Generated from the local source snapshot on 2026-09-12. This page documents implemented code and does not certify a deployed service, permissions configuration, or successful provider operation.

Source file: minds-ui/apps/api-service/app/api/v1/services/[id]/bind/route.ts. SHA-256: 46eb70661597bee95e27cd3bc402a25cdafac3c2508eb033a5f8d293a18996a0.

On this page