API referencePlatform APIEndpoint reference
GUIDE & REFERENCE

/api/v1/bundles/expand (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/bundles/expand
Path parametersNone
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.

BundleExpansionRequest

BundleExpansionRequest = z.object({
  bundle_name: z.string(),
  base_slug: z.string().regex(/^[a-z0-9-]+$/),
  plan: ServicePlanName.default('free'),
  region: z.string().default('us-east-1'),
  tenant_id: z.string().optional(),
  service_overrides: z
    .record(
      z.object({
        config: z.record(z.unknown()).optional(),
        plan: ServicePlanName.optional(),
      }),
    )
    .optional(),
})

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

BundleExpansionRequest

export type BundleExpansionRequest = z.infer<typeof BundleExpansionRequest>

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

BundleExpansionResponse

BundleExpansionResponse = z.object({
  bundle_name: z.string(),
  services: z.array(CreateServiceResponse),
  total_services: z.number().int(),
  estimated_ready_in: z.number().int(),
})

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

BundleExpansionResponse

export type BundleExpansionResponse = z.infer<typeof BundleExpansionResponse>

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

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) {
  const requestId = generateRequestId()
  let rateLimitInfo: RateLimitMetadata | undefined

  try {
    const authContext = await resolveAuthContext(request)
    const body = await validateBody(request, BundleExpansionRequest)

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

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

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

    const result = await expandBundle(authContext, {
      ...body,
      plan: body.plan ?? 'free',
      region: body.region ?? 'us-east-1',
    })

    const response = apiAccepted<BundleExpansionResponse>(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 expand bundle:', error)
    const response = apiError(
      new ApiError(500, 'INTERNAL_ERROR', 'Failed to expand bundle'),
      requestId,
    )
    return withRequestMetadata(response, requestId, rateLimitInfo)
  }
}

Source: minds-ui/apps/api-service/app/api/v1/bundles/expand/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/bundles/expand/route.ts:41.

apiAccepted<BundleExpansionResponse>(result)

Source: minds-ui/apps/api-service/app/api/v1/bundles/expand/route.ts:50.

apiError(error, requestId)

Source: minds-ui/apps/api-service/app/api/v1/bundles/expand/route.ts:54.

apiError(
      new ApiError(500, 'INTERNAL_ERROR', 'Failed to expand bundle'),
      requestId,
    )

Source: minds-ui/apps/api-service/app/api/v1/bundles/expand/route.ts:58.

new ApiError(500, 'INTERNAL_ERROR', 'Failed to expand bundle')

Source: minds-ui/apps/api-service/app/api/v1/bundles/expand/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/bundles/expand/route.ts. SHA-256: 3935a917f29cef61b6044c9c8005600bb7ae664135e6a4579ea0f94b53ad7909.

On this page