> ## Documentation Index
> Fetch the complete documentation index at: https://docs.costgraph.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get placement alternatives

> Returns ranked placement alternatives for a resource owned by the tenant selected by the X-CostGraph-Tenant-ID header



## OpenAPI

````yaml /api-reference/costgraph/openapi.json get /api/v1/tenant/placement-alternatives/{resource_type}/{resource_id}
openapi: 3.0.0
info:
  description: Read and manage your CostGraph organization, spend, alerts, and settings.
  title: CostGraph API
  contact: {}
  version: '1.0'
servers:
  - url: https://api.costgraph.ai
security: []
tags:
  - name: ai
    x-group: AI
  - name: ai-serving
    x-group: AI serving
  - name: anomalies
    x-group: Anomalies
  - name: auth
    x-group: Auth
  - name: billing
    x-group: Billing
  - name: billing-export
    x-group: Billing export
  - name: budgets
    x-group: Budgets
  - name: ci
    x-group: CI
  - name: compute-recommendations
    x-group: Compute recommendations
  - name: config
    x-group: Config
  - name: cost
    x-group: Cost
  - name: gpus
    x-group: GPUs
  - name: graphai
    x-group: Graph AI
  - name: infracost
    x-group: Infracost
  - name: integrations
    x-group: Integrations
  - name: invitations
    x-group: Invitations
  - name: kubernetes-clusters
    x-group: Kubernetes clusters
  - name: marketplace
    x-group: Marketplace
  - name: network-requests
    x-group: Network requests
  - name: notifications
    x-group: Notifications
  - name: oauth
    x-group: OAuth
  - name: oauth-clients
    x-group: OAuth clients
  - name: opencost
    x-group: OpenCost
  - name: organization
    x-group: Audit log
  - name: organizations
    x-group: Organizations
  - name: placement-alternatives
    x-group: Placement alternatives
  - name: reports
    x-group: Reports
  - name: service-map
    x-group: Service map
  - name: settings
    x-group: Settings
  - name: sso
    x-group: Single sign-on
  - name: tenants
    x-group: Tenants
  - name: user
    x-group: Users
  - name: virtual-machines
    x-group: Virtual machines
  - name: virtual-tags
    x-group: Virtual tags
  - name: workflows
    x-group: Workflows
paths:
  /api/v1/tenant/placement-alternatives/{resource_type}/{resource_id}:
    get:
      tags:
        - placement-alternatives
      summary: Get placement alternatives
      description: >-
        Returns ranked placement alternatives for a resource owned by the tenant
        selected by the X-CostGraph-Tenant-ID header
      parameters:
        - description: Tenant ID
          name: X-CostGraph-Tenant-ID
          in: header
          required: true
          schema:
            type: string
        - description: Resource type, currently managed_database
          name: resource_type
          in: path
          required: true
          schema:
            type: string
        - description: Resource ID
          name: resource_id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/responses.SuccessResponse'
                  - type: object
                    properties:
                      data:
                        type: array
                        items:
                          $ref: '#/components/schemas/db.PlacementAlternative'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    responses.SuccessResponse:
      type: object
      required:
        - message
        - status
      properties:
        data: {}
        message:
          type: string
          example: some message
        status:
          type: string
          example: success
    db.PlacementAlternative:
      type: object
      properties:
        alternative_kind:
          description: >-
            Which dimension the alternative changes: cross_provider (built now),

            cross_region (same provider, cheaper region), cross_product (same
            provider,

            different product e.g. RDS -> Aurora). Set by the caller; no
            default.
          type: string
        caveats:
          description: >-
            JSON array of honesty flags: list_price, excludes_migration_egress,

            verify_parity, oversized_min (disproportionate fit),

            source_cost_modeled_from_hourly_pricing (no invoice baseline).
            Single source

            of truth for caveats.
          type: object
        continent_match:
          type: boolean
        created_at:
          type: string
        distance_km:
          type: number
        id:
          type: string
        metadata:
          description: >-
            Snapshot of type-specific target fields for display without a
            type-specific

            join: e.g. {instance_type, cpu_cores, ram_gb, source_deployment,
            node_count,

            storage_gb}.
          type: object
        reason:
          type: string
        resource_id:
          description: >-
            Id of the source resource this alternative is for (e.g. databases.id
            when

            resource_type = managed_database). Joins the table named by
            resource_table.
          type: string
        resource_table:
          description: >-
            Name of the table the source resource lives in (e.g. databases for

            managed_database), so resource_id can be resolved without a
            resource_type ->

            table lookup.
          type: string
        resource_type:
          description: >-
            Polymorphic source resource kind (e.g. managed_database). Pair with

            resource_id to join the source resource (databases.id for
            managed_database).
          type: string
        savings_monthly_usd:
          description: >-
            source_monthly_usd - target_monthly_usd. Positive = target is
            cheaper.

            Display ordering: savings_monthly_usd DESC (rank is derived, not
            stored).
          type: number
        savings_percent:
          type: number
        source_monthly_usd:
          description: >-
            Baseline cost of the resource today: the actual provider-invoice
            bill when

            available (cost_usage_hourly, pricing_source = provider_invoice),
            else the

            modeled current cost (caveat
            source_cost_modeled_from_hourly_pricing).
          type: number
        tags:
          description: >-
            Flat JSON object of string keys to string values, for filtering and

            annotation. Same shape as tags on inventory tables (instances,
            disks,

            k8s_clusters); defaults to {} and is never null.
          type: object
        target_monthly_usd:
          description: >-
            Assembled modeled cost of the right-sized footprint on the target:

            instance(cost_per_hour x node_count x 730) + storage(gib x
            region_rate x 730)

            [+ future dims]. List price, never a bill (see caveat list_price).
          type: number
        target_pricing_id:
          description: >-
            Nullable FK-by-value to the target pricing row (database_pricings.id
            for

            managed_database). Null for rate-card target types (e.g. object
            storage) with

            no SKU row; read metadata then.
          type: string
        target_provider:
          description: |-
            Target cloud/provider the alternative runs on (e.g. AWS, GCP, Azure,
            PlanetScale).
          type: string
        target_region:
          description: Target region the alternative is priced in.
          type: string
        target_service:
          description: Target service/product (e.g. AmazonRDS, AlloyDB, PlanetScale).
          type: string
        tenant_id:
          type: string
        updated_at:
          type: string
    responses.ErrorResponse:
      type: object
      required:
        - message
        - status
      properties:
        message:
          type: string
          example: some message
        status:
          type: string
          example: error
  securitySchemes:
    BearerAuth:
      description: Enter "Bearer {token}"
      type: apiKey
      name: Authorization
      in: header

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.