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

# Create a billing datasource



## OpenAPI

````yaml https://app-api.costory.io/docs/openapi.json post /terraform/billingDatasources
openapi: 3.0.0
info:
  title: Costory
  version: '1.0'
  description: API Documentation
servers:
  - url: ''
    description: Production server
security: []
paths:
  /terraform/billingDatasources:
    post:
      tags:
        - Admin Billing Datasources
      summary: Create a billing datasource
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AdminBillingDatasourceCreate'
      responses:
        '201':
          description: Billing datasource created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdminCreateBillingDatasourceResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequest'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Unauthorized'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequest'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFound'
      security:
        - bearerAuth: []
        - apiKeyAuth: []
components:
  schemas:
    AdminBillingDatasourceCreate:
      oneOf:
        - type: object
          properties:
            name:
              type: string
            type:
              type: string
              enum:
                - GCP
            bqTablePath:
              type: string
            isDetailedBilling:
              type: boolean
            startDate:
              type: string
              nullable: true
              format: date-time
            endDate:
              type: string
              nullable: true
              format: date-time
          required:
            - name
            - type
            - bqTablePath
        - type: object
          properties:
            name:
              type: string
            type:
              type: string
              enum:
                - Azure
            clientId:
              type: string
              format: uuid
            tenantId:
              type: string
              format: uuid
            containerName:
              type: string
              minLength: 1
            storageAccountName:
              type: string
              minLength: 1
              pattern: ^[a-z0-9]{3,24}$
            actualsPath:
              type: string
              minLength: 1
            amortizedPath:
              type: string
              minLength: 1
          required:
            - name
            - type
            - clientId
            - tenantId
            - containerName
            - storageAccountName
            - actualsPath
            - amortizedPath
        - type: object
          properties:
            name:
              type: string
            type:
              type: string
              enum:
                - AWS
            bucketName:
              type: string
            roleArn:
              type: string
              pattern: ^arn:aws:iam::\d{12}:role\/[\w+=,.@-]+$
            prefix:
              type: string
              default: ''
            eksSplitDataEnabled:
              type: boolean
              default: false
            startDate:
              type: string
              nullable: true
              format: date-time
            endDate:
              type: string
              nullable: true
              format: date-time
            eksSplit:
              type: boolean
          required:
            - name
            - type
            - bucketName
            - roleArn
        - type: object
          properties:
            name:
              type: string
            type:
              type: string
              enum:
                - Cursor
            adminApiKey:
              type: string
              minLength: 1
            startDate:
              type: string
              nullable: true
              format: date-time
            endDate:
              type: string
              nullable: true
              format: date-time
          required:
            - name
            - type
            - adminApiKey
        - type: object
          properties:
            name:
              type: string
            type:
              type: string
              enum:
                - Anthropic
            adminApiKey:
              type: string
              minLength: 1
            startDate:
              type: string
              nullable: true
              format: date-time
            endDate:
              type: string
              nullable: true
              format: date-time
          required:
            - name
            - type
            - adminApiKey
        - type: object
          properties:
            name:
              type: string
              minLength: 1
            type:
              type: string
              enum:
                - AnthropicClaudeAi
            analyticsApiKey:
              type: string
              minLength: 1
            accountName:
              type: string
              minLength: 1
            startDate:
              type: string
              nullable: true
              format: date-time
          required:
            - name
            - type
            - analyticsApiKey
            - accountName
        - type: object
          properties:
            name:
              type: string
            type:
              type: string
              enum:
                - ElasticCloud
            apiKey:
              type: string
              minLength: 1
            organizationId:
              type: string
              minLength: 1
            startDate:
              type: string
              nullable: true
              format: date-time
          required:
            - name
            - type
            - apiKey
            - organizationId
        - type: object
          properties:
            name:
              type: string
            type:
              type: string
              enum:
                - ClickHouseCloud
            keyId:
              type: string
              minLength: 1
            keySecret:
              type: string
              minLength: 1
            organizationId:
              type: string
              minLength: 1
            startDate:
              type: string
              nullable: true
              format: date-time
          required:
            - name
            - type
            - keyId
            - keySecret
            - organizationId
        - type: object
          properties:
            name:
              type: string
              minLength: 1
            type:
              type: string
              enum:
                - Cloudflare
            apiToken:
              type: string
              minLength: 1
            accountId:
              type: string
              minLength: 1
            startDate:
              type: string
              nullable: true
              format: date-time
          required:
            - name
            - type
            - apiToken
            - accountId
        - type: object
          properties:
            name:
              type: string
            type:
              type: string
              enum:
                - Scaleway
            secretKey:
              type: string
              minLength: 1
            organizationId:
              type: string
              minLength: 1
            accessKey:
              type: string
            startDate:
              type: string
              nullable: true
              format: date-time
          required:
            - name
            - type
            - secretKey
            - organizationId
        - type: object
          properties:
            name:
              type: string
              minLength: 1
            type:
              type: string
              enum:
                - OpenAI
            adminApiKey:
              type: string
              minLength: 1
            startDate:
              type: string
              nullable: true
              format: date-time
          required:
            - name
            - type
            - adminApiKey
        - type: object
          properties:
            name:
              type: string
              minLength: 1
            type:
              type: string
              enum:
                - OpenRouter
            managementKey:
              type: string
              minLength: 1
            organizationName:
              type: string
              nullable: true
              minLength: 1
            startDate:
              type: string
              nullable: true
              format: date-time
          required:
            - name
            - type
            - managementKey
        - type: object
          properties:
            name:
              type: string
              minLength: 1
            type:
              type: string
              enum:
                - ElevenLabs
            apiToken:
              type: string
              minLength: 1
            region:
              type: string
              nullable: true
              enum:
                - us
                - eu
                - in
                - sg
                - null
            startDate:
              type: string
              nullable: true
              format: date-time
          required:
            - name
            - type
            - apiToken
        - type: object
          properties:
            name:
              type: string
              minLength: 1
            type:
              type: string
              enum:
                - KlingAi
            apiKey:
              type: string
              minLength: 1
            region:
              type: string
              nullable: true
              enum:
                - singapore
                - beijing
                - null
            startDate:
              type: string
              nullable: true
              format: date-time
          required:
            - name
            - type
            - apiKey
        - type: object
          properties:
            name:
              type: string
              minLength: 1
            type:
              type: string
              enum:
                - SeedanceAi
            accessKeyId:
              type: string
              minLength: 1
            secretAccessKey:
              type: string
              minLength: 1
            region:
              type: string
              nullable: true
              minLength: 1
            startDate:
              type: string
              nullable: true
              format: date-time
          required:
            - name
            - type
            - accessKeyId
            - secretAccessKey
        - type: object
          properties:
            name:
              type: string
              minLength: 1
            type:
              type: string
              enum:
                - OCI
            userOcid:
              type: string
              minLength: 1
            tenancyOcid:
              type: string
              minLength: 1
            region:
              type: string
              minLength: 1
              pattern: ^[a-zA-Z0-9-]+$
            privateKeyPem:
              type: string
              minLength: 1
            fingerprint:
              type: string
              minLength: 1
            prefix:
              type: string
              nullable: true
              minLength: 1
          required:
            - name
            - type
            - userOcid
            - tenancyOcid
            - region
            - privateKeyPem
        - type: object
          properties:
            name:
              type: string
              minLength: 1
            type:
              type: string
              enum:
                - NEBIUS
            accessKeyId:
              type: string
              minLength: 1
            secretAccessKey:
              type: string
              minLength: 1
            bucket:
              type: string
              minLength: 1
            region:
              type: string
              enum:
                - eu-north1
                - eu-west1
            prefix:
              type: string
              nullable: true
              minLength: 1
          required:
            - name
            - type
            - accessKeyId
            - secretAccessKey
            - bucket
            - region
        - type: object
          properties:
            name:
              type: string
              minLength: 1
            type:
              type: string
              enum:
                - DATABRICKS
            storagePath:
              type: string
              minLength: 1
              pattern: ^gs:\/\/[^/]+\/\S+$
            discountPct:
              type: integer
              nullable: true
              minimum: 1
              maximum: 100
          required:
            - name
            - type
            - storagePath
        - type: object
          properties:
            name:
              type: string
              minLength: 1
            type:
              type: string
              enum:
                - CircleCI
            apiToken:
              type: string
              minLength: 1
            organizationId:
              type: string
              format: uuid
            startDate:
              type: string
              nullable: true
              format: date-time
            creditUsd:
              type: number
              nullable: true
              minimum: 0
              exclusiveMinimum: true
          required:
            - name
            - type
            - apiToken
            - organizationId
        - type: object
          properties:
            name:
              type: string
              minLength: 1
            type:
              type: string
              enum:
                - CustomBigQuery
            mapping:
              type: object
              properties:
                billedCost:
                  type: string
                  minLength: 1
                subAccountId:
                  type: string
                serviceName:
                  type: string
                billingPeriodStart:
                  type: string
                billingPeriodEnd:
                  type: string
                chargePeriodStart:
                  type: string
                chargePeriodEnd:
                  type: string
                chargeDescription:
                  type: string
                billingCurrency:
                  type: string
                contractedCost:
                  type: string
                billingAccountId:
                  type: string
                originalBillingCurrency:
                  type: string
                chargeCategory:
                  type: string
                chargeFrequency:
                  type: string
                commitmentDiscountCategory:
                  type: string
                commitmentDiscountId:
                  type: string
                commitmentDiscountType:
                  type: string
                consumedQuantity:
                  type: string
                consumedUnit:
                  type: string
                effectiveCost:
                  type: string
                invoiceIssuer:
                  type: string
                listCost:
                  type: string
                listUnitPrice:
                  type: string
                pricingCategory:
                  type: string
                pricingQuantity:
                  type: string
                pricingUnit:
                  type: string
                provider:
                  type: string
                publisher:
                  type: string
                regionId:
                  type: string
                resourceId:
                  type: string
                resourceName:
                  type: string
                resourceType:
                  type: string
                categoryFocus:
                  type: string
                skuId:
                  type: string
                sku:
                  type: string
                skuPriceId:
                  type: string
                tags:
                  type: string
              required:
                - billedCost
            bqTablePath:
              type: string
            providerName:
              type: string
            billingAccountId:
              type: string
            startDate:
              type: string
              nullable: true
              format: date-time
            endDate:
              type: string
              nullable: true
              format: date-time
          required:
            - name
            - type
            - mapping
            - bqTablePath
            - providerName
        - type: object
          properties:
            name:
              type: string
              minLength: 1
            type:
              type: string
              enum:
                - CONFLUENT
            apiKey:
              type: string
            apiSecret:
              type: string
          required:
            - name
            - type
            - apiKey
            - apiSecret
        - type: object
          properties:
            name:
              type: string
              minLength: 1
            type:
              type: string
              enum:
                - Datadog
            apiKey:
              type: string
              minLength: 1
            applicationKey:
              type: string
              minLength: 1
            region:
              type: string
              minLength: 1
          required:
            - name
            - type
            - apiKey
            - applicationKey
            - region
        - type: object
          properties:
            name:
              type: string
              minLength: 1
            type:
              type: string
              enum:
                - Aiven
            apiSecret:
              type: string
              minLength: 1
            organizationId:
              type: string
              minLength: 1
          required:
            - name
            - type
            - apiSecret
            - organizationId
        - type: object
          properties:
            name:
              type: string
              minLength: 1
            type:
              type: string
              enum:
                - GCP_CUD_EXPORT
            bqTablePath:
              type: string
              minLength: 1
              pattern: >-
                ^[a-zA-Z][a-zA-Z0-9_-]*\.[a-zA-Z_][a-zA-Z0-9_]*\.[a-zA-Z_][a-zA-Z0-9_]*$
          required:
            - name
            - type
            - bqTablePath
        - type: object
          properties:
            name:
              type: string
              minLength: 1
            type:
              type: string
              enum:
                - SNOWFLAKE
            integrationId:
              type: string
              minLength: 1
          required:
            - name
            - type
            - integrationId
      discriminator:
        propertyName: type
    AdminCreateBillingDatasourceResponse:
      allOf:
        - oneOf:
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - GCP
                bqUri:
                  type: string
                startDate:
                  type: string
                  nullable: true
                  format: date-time
                endDate:
                  type: string
                  nullable: true
                  format: date-time
                isDetailedBilling:
                  type: boolean
                status:
                  type: string
              required:
                - name
                - type
                - bqUri
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - Azure
                storageAccountName:
                  type: string
                containerName:
                  type: string
                actualsPath:
                  type: string
                amortizedPath:
                  type: string
                clientId:
                  type: string
                tenantId:
                  type: string
                status:
                  type: string
              required:
                - name
                - type
                - storageAccountName
                - containerName
                - actualsPath
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - AWS
                bucketName:
                  type: string
                roleArn:
                  type: string
                prefix:
                  type: string
                eksSplitDataEnabled:
                  type: boolean
                  default: false
                startDate:
                  type: string
                  nullable: true
                  format: date-time
                endDate:
                  type: string
                  nullable: true
                  format: date-time
                eksSplit:
                  type: boolean
                status:
                  type: string
              required:
                - name
                - type
                - bucketName
                - roleArn
                - prefix
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - Cursor
                bqTableUri:
                  type: string
                startDate:
                  type: string
                  nullable: true
                  format: date-time
                endDate:
                  type: string
                  nullable: true
                  format: date-time
                status:
                  type: string
              required:
                - name
                - type
                - bqTableUri
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - Anthropic
                bqTableUri:
                  type: string
                startDate:
                  type: string
                  nullable: true
                  format: date-time
                endDate:
                  type: string
                  nullable: true
                  format: date-time
                status:
                  type: string
              required:
                - name
                - type
                - bqTableUri
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - AnthropicClaudeAi
                bqTableUri:
                  type: string
                startDate:
                  type: string
                  nullable: true
                  format: date-time
                status:
                  type: string
              required:
                - name
                - type
                - bqTableUri
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - ElasticCloud
                bqTableUri:
                  type: string
                startDate:
                  type: string
                  nullable: true
                  format: date-time
                status:
                  type: string
              required:
                - name
                - type
                - bqTableUri
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - ClickHouseCloud
                bqTableUri:
                  type: string
                startDate:
                  type: string
                  nullable: true
                  format: date-time
                status:
                  type: string
              required:
                - name
                - type
                - bqTableUri
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - Cloudflare
                bqTableUri:
                  type: string
                startDate:
                  type: string
                  nullable: true
                  format: date-time
                status:
                  type: string
              required:
                - name
                - type
                - bqTableUri
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - Scaleway
                bqTableUri:
                  type: string
                startDate:
                  type: string
                  nullable: true
                  format: date-time
                status:
                  type: string
              required:
                - name
                - type
                - bqTableUri
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - OpenAI
                bqTableUri:
                  type: string
                startDate:
                  type: string
                  nullable: true
                  format: date-time
                status:
                  type: string
              required:
                - name
                - type
                - bqTableUri
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - OpenRouter
                bqTableUri:
                  type: string
                startDate:
                  type: string
                  nullable: true
                  format: date-time
                status:
                  type: string
              required:
                - name
                - type
                - bqTableUri
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - ElevenLabs
                bqTableUri:
                  type: string
                startDate:
                  type: string
                  nullable: true
                  format: date-time
                status:
                  type: string
              required:
                - name
                - type
                - bqTableUri
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - KlingAi
                bqTableUri:
                  type: string
                startDate:
                  type: string
                  nullable: true
                  format: date-time
                status:
                  type: string
              required:
                - name
                - type
                - bqTableUri
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - SeedanceAi
                bqTableUri:
                  type: string
                startDate:
                  type: string
                  nullable: true
                  format: date-time
                status:
                  type: string
              required:
                - name
                - type
                - bqTableUri
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - OCI
                tenancyOcid:
                  type: string
                userOcid:
                  type: string
                region:
                  type: string
                prefix:
                  type: string
                destination:
                  type: string
                fingerprint:
                  type: string
                status:
                  type: string
              required:
                - name
                - type
                - tenancyOcid
                - userOcid
                - region
                - prefix
                - destination
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - NEBIUS
                bucket:
                  type: string
                region:
                  type: string
                prefix:
                  type: string
                destination:
                  type: string
                status:
                  type: string
              required:
                - name
                - type
                - bucket
                - region
                - destination
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - DATABRICKS
                storagePath:
                  type: string
                discountPct:
                  type: integer
                  minimum: 1
                  maximum: 100
                bqUri:
                  type: string
                status:
                  type: string
              required:
                - name
                - type
                - storagePath
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - CircleCI
                bqTableUri:
                  type: string
                startDate:
                  type: string
                  nullable: true
                  format: date-time
                creditUsd:
                  type: number
                  nullable: true
                  minimum: 0
                  exclusiveMinimum: true
                status:
                  type: string
              required:
                - name
                - type
                - bqTableUri
            - type: object
              properties:
                name:
                  type: string
                  minLength: 1
                type:
                  type: string
                  enum:
                    - CustomBigQuery
                mapping:
                  type: object
                  properties:
                    billedCost:
                      type: string
                      minLength: 1
                    subAccountId:
                      type: string
                    serviceName:
                      type: string
                    billingPeriodStart:
                      type: string
                    billingPeriodEnd:
                      type: string
                    chargePeriodStart:
                      type: string
                    chargePeriodEnd:
                      type: string
                    chargeDescription:
                      type: string
                    billingCurrency:
                      type: string
                    contractedCost:
                      type: string
                    billingAccountId:
                      type: string
                    originalBillingCurrency:
                      type: string
                    chargeCategory:
                      type: string
                    chargeFrequency:
                      type: string
                    commitmentDiscountCategory:
                      type: string
                    commitmentDiscountId:
                      type: string
                    commitmentDiscountType:
                      type: string
                    consumedQuantity:
                      type: string
                    consumedUnit:
                      type: string
                    effectiveCost:
                      type: string
                    invoiceIssuer:
                      type: string
                    listCost:
                      type: string
                    listUnitPrice:
                      type: string
                    pricingCategory:
                      type: string
                    pricingQuantity:
                      type: string
                    pricingUnit:
                      type: string
                    provider:
                      type: string
                    publisher:
                      type: string
                    regionId:
                      type: string
                    resourceId:
                      type: string
                    resourceName:
                      type: string
                    resourceType:
                      type: string
                    categoryFocus:
                      type: string
                    skuId:
                      type: string
                    sku:
                      type: string
                    skuPriceId:
                      type: string
                    tags:
                      type: string
                  required:
                    - billedCost
                bqTablePath:
                  type: string
                providerName:
                  type: string
                billingAccountId:
                  type: string
                startDate:
                  type: string
                  nullable: true
                  format: date-time
                endDate:
                  type: string
                  nullable: true
                  format: date-time
                status:
                  type: string
              required:
                - name
                - type
                - mapping
                - bqTablePath
                - providerName
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - CONFLUENT
                bqTableUri:
                  type: string
                status:
                  type: string
              required:
                - name
                - type
                - bqTableUri
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - Datadog
                integrationId:
                  type: string
                bqTableUri:
                  type: string
                status:
                  type: string
              required:
                - name
                - type
                - integrationId
                - bqTableUri
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - Aiven
                organizationId:
                  type: string
                bqTableUri:
                  type: string
                status:
                  type: string
              required:
                - name
                - type
                - organizationId
                - bqTableUri
            - type: object
              properties:
                name:
                  type: string
                  minLength: 1
                type:
                  type: string
                  enum:
                    - GCP_CUD_EXPORT
                bqTablePath:
                  type: string
                  minLength: 1
                  pattern: >-
                    ^[a-zA-Z][a-zA-Z0-9_-]*\.[a-zA-Z_][a-zA-Z0-9_]*\.[a-zA-Z_][a-zA-Z0-9_]*$
                status:
                  type: string
              required:
                - name
                - type
                - bqTablePath
            - type: object
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - SNOWFLAKE
                integrationId:
                  type: string
                bqTableUris:
                  type: array
                  items:
                    type: string
                status:
                  type: string
              required:
                - name
                - type
                - integrationId
                - bqTableUris
          discriminator:
            propertyName: type
        - type: object
          properties:
            id:
              type: string
          required:
            - id
    BadRequest:
      type: object
      properties:
        error:
          type: string
          description: Error code
        reason:
          type: string
          description: Human-readable reason
        details:
          description: Additional details
        summary:
          type: string
          description: Optional short summary
      required:
        - error
    Unauthorized:
      type: object
      properties:
        error:
          type: string
          description: Unauthorized error message
      required:
        - error
    NotFound:
      type: object
      properties:
        error:
          type: string
          description: Resource not found error code
      required:
        - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT or Clerk ak_* API key
      description: >-
        Send `Authorization: Bearer <credential>` using either a Clerk session
        JWT or a Clerk API key (`ak_*`). API keys may identify a user (`user_*`)
        or organization (`org_*`) principal and are generated in the Clerk
        Dashboard under API keys.
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-token
      description: >-
        API token for authentication (or Admin API key). The token is scoped per
        organization and can be retrieved in the Organization Switcher.

````

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