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

# Update Stripe Configuration

> Create or update Stripe payment configuration for a project

Create or update the Stripe payment configuration for a project. Supports both test and live credentials. This endpoint creates a new configuration if none exists, or updates the existing one.

## Authentication

<Note>
  This endpoint requires developer authentication via OAuth2 Bearer Token. You must own the project.
</Note>

## Path Parameters

<ParamField path="project_id" type="string (UUID)" required>
  The unique identifier of the project
</ParamField>

## Request Body

All fields are optional. Only provide the credentials you want to configure or update.

<ParamField body="test_secret_key" type="string">
  Stripe test mode secret key (starts with `sk_test_`)
</ParamField>

<ParamField body="test_publishable_key" type="string">
  Stripe test mode publishable key (starts with `pk_test_`)
</ParamField>

<ParamField body="test_webhook_secret" type="string">
  Stripe test mode webhook signing secret (starts with `whsec_`)
</ParamField>

<ParamField body="live_secret_key" type="string">
  Stripe live mode secret key (starts with `sk_live_`)
</ParamField>

<ParamField body="live_publishable_key" type="string">
  Stripe live mode publishable key (starts with `pk_live_`)
</ParamField>

<ParamField body="live_webhook_secret" type="string">
  Stripe live mode webhook signing secret (starts with `whsec_`)
</ParamField>

## Example Request

Configure test mode credentials:

```bash theme={null}
curl -X PUT "https://api.devkit4ai.com/api/v1/payments/stripe/projects/550e8400-e29b-41d4-a716-446655440000/config" \
  -H "Authorization: Bearer {developer_jwt}" \
  -H "Content-Type: application/json" \
  -d '{
    "test_secret_key": "sk_test_51ABC...",
    "test_publishable_key": "pk_test_51ABC...",
    "test_webhook_secret": "whsec_ABC..."
  }'
```

## Example Response

```json theme={null}
{
  "id": "770e8400-e29b-41d4-a716-446655440000",
  "project_id": "550e8400-e29b-41d4-a716-446655440000",
  "is_active": true,
  "has_test_credentials": true,
  "has_live_credentials": false,
  "test_secret_key_masked": "sk_test_...aBcD",
  "test_publishable_key_masked": "pk_test_...eFgH",
  "test_webhook_secret_masked": "whsec_...iJkL",
  "live_secret_key_masked": null,
  "live_publishable_key_masked": null,
  "live_webhook_secret_masked": null,
  "test_configured_at": "2026-01-24T10:00:00Z",
  "live_configured_at": null,
  "created_at": "2026-01-24T10:00:00Z",
  "updated_at": "2026-01-24T10:00:00Z"
}
```

## Configuration Flow

```mermaid theme={null}
sequenceDiagram
    participant D as Developer
    participant API as Cloud API
    participant DB as Database
    participant Stripe as Stripe Dashboard

    D->>Stripe: 1. Get API keys from dashboard
    Stripe-->>D: Secret key, Publishable key
    D->>Stripe: 2. Create webhook endpoint
    Stripe-->>D: Webhook signing secret
    D->>API: 3. PUT /stripe/projects/{id}/config
    API->>DB: Store encrypted credentials
    DB-->>API: Configuration saved
    API-->>D: Return masked config
```

## Getting Stripe Credentials

<Steps>
  <Step title="Create Stripe Account">
    Sign up at [stripe.com](https://stripe.com) if you haven't already.
  </Step>

  <Step title="Get API Keys">
    Navigate to **Developers > API keys** in the Stripe Dashboard.

    (((REPLACE\_THIS\_WITH\_IMAGE: stripe-dashboard-api-keys.png: Stripe Dashboard showing API keys section with publishable and secret keys)))
  </Step>

  <Step title="Create Webhook Endpoint">
    Navigate to **Developers > Webhooks** and create an endpoint using the URL from [Get Webhook URLs](/cloud-api/payments/stripe/get-webhook-urls).
  </Step>

  <Step title="Get Webhook Secret">
    After creating the webhook, reveal and copy the signing secret.
  </Step>
</Steps>

## Credential Validation

<Tip>
  Before saving, validate your credentials using the [Validate Credentials](/cloud-api/payments/stripe/validate-credentials) endpoint to ensure they work correctly.
</Tip>

## Partial Updates

You can update credentials incrementally. For example, to add live credentials to an existing test configuration:

```bash theme={null}
curl -X PUT "https://api.devkit4ai.com/api/v1/payments/stripe/projects/{project_id}/config" \
  -H "Authorization: Bearer {developer_jwt}" \
  -H "Content-Type: application/json" \
  -d '{
    "live_secret_key": "sk_live_51ABC...",
    "live_publishable_key": "pk_live_51ABC...",
    "live_webhook_secret": "whsec_XYZ..."
  }'
```

## Error Responses

| Status | Description                                      |
| ------ | ------------------------------------------------ |
| `401`  | Unauthorized - Invalid or missing authentication |
| `403`  | Forbidden - You don't own this project           |
| `404`  | Project not found                                |
| `422`  | Validation error - Invalid key format            |

## Security

<Warning>
  * Never commit Stripe secret keys to version control
  * Use environment variables in your application
  * Rotate keys immediately if they are exposed
  * Use test mode keys for development and testing
</Warning>

## Related Pages

<CardGroup cols={2}>
  <Card title="Get Stripe Config" icon="gear" href="/cloud-api/payments/stripe/get-config">
    View current configuration
  </Card>

  <Card title="Validate Credentials" icon="check" href="/cloud-api/payments/stripe/validate-credentials">
    Test credentials before saving
  </Card>

  <Card title="Get Webhook URLs" icon="webhook" href="/cloud-api/payments/stripe/get-webhook-urls">
    Get webhook endpoint URLs
  </Card>
</CardGroup>


## OpenAPI

````yaml PUT /api/v1/payments/stripe/projects/{project_id}/config
openapi: 3.1.0
info:
  title: Dev Kit for AI API
  description: 'API for Dev Kit for AI: Developer Toolkit for AI-Powered Web Applications'
  version: 1.6.1
servers:
  - url: https://api.devkit4ai.com
    description: Dev Kit for AI Production Server
  - url: https://api.vibecoding.ad
    description: Vibe Coding Production Server
security: []
paths:
  /api/v1/payments/stripe/projects/{project_id}/config:
    put:
      tags:
        - Stripe Configuration
      summary: Update Stripe Configuration
      description: >-
        Create or update Stripe payment configuration for a project. Supports
        both test and live credentials.
      operationId: >-
        update_stripe_config_api_v1_payments_stripe_projects__project_id__config_put
      parameters:
        - name: project_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Project Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StripeConfigRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StripeConfigResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - OAuth2PasswordBearer: []
components:
  schemas:
    StripeConfigRequest:
      properties:
        test_secret_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Test Secret Key
        test_publishable_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Test Publishable Key
        test_webhook_secret:
          anyOf:
            - type: string
            - type: 'null'
          title: Test Webhook Secret
        live_secret_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Live Secret Key
        live_publishable_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Live Publishable Key
        live_webhook_secret:
          anyOf:
            - type: string
            - type: 'null'
          title: Live Webhook Secret
      type: object
      title: StripeConfigRequest
      description: Request to create/update Stripe configuration.
    StripeConfigResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        project_id:
          type: string
          format: uuid
          title: Project Id
        is_active:
          type: boolean
          title: Is Active
        has_test_credentials:
          type: boolean
          title: Has Test Credentials
        has_live_credentials:
          type: boolean
          title: Has Live Credentials
        test_secret_key_masked:
          anyOf:
            - type: string
            - type: 'null'
          title: Test Secret Key Masked
        test_publishable_key_masked:
          anyOf:
            - type: string
            - type: 'null'
          title: Test Publishable Key Masked
        test_webhook_secret_masked:
          anyOf:
            - type: string
            - type: 'null'
          title: Test Webhook Secret Masked
        live_secret_key_masked:
          anyOf:
            - type: string
            - type: 'null'
          title: Live Secret Key Masked
        live_publishable_key_masked:
          anyOf:
            - type: string
            - type: 'null'
          title: Live Publishable Key Masked
        live_webhook_secret_masked:
          anyOf:
            - type: string
            - type: 'null'
          title: Live Webhook Secret Masked
        test_configured_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Test Configured At
        live_configured_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Live Configured At
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Updated At
      type: object
      required:
        - id
        - project_id
        - is_active
        - has_test_credentials
        - has_live_credentials
        - created_at
      title: StripeConfigResponse
      description: Stripe configuration response with masked credentials.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    OAuth2PasswordBearer:
      type: oauth2
      flows:
        password:
          scopes: {}
          tokenUrl: auth/login

````