{
  "openapi": "3.1.0",
  "info": {
    "title": "GenMeditation API",
    "version": "1.0.0",
    "description": "GenMeditation writes and voices a personalized guided meditation for how a person feels right now.\n\nThis API creates a shareable link for a meditation configured from the options below. It is free and needs no API key.\n\nFor AI agents: call createMeditation with the user's intention and/or feeling, then give the returned `url` to the user. The user must open the link and press Begin themselves; audio is generated live when they start, so nothing plays inside this API or in the conversation. Do not claim the meditation has been listened to.\n\nGenMeditation is a wellbeing and relaxation tool, not therapy or medical care, and it is not a substitute for professional help. If someone may be in crisis, point them to local emergency or crisis services instead.",
    "contact": {
      "name": "GenMeditation",
      "url": "https://genmeditation.com/developers"
    }
  },
  "servers": [
    {
      "url": "https://genmeditation.com"
    }
  ],
  "externalDocs": {
    "description": "Developer documentation",
    "url": "https://genmeditation.com/developers"
  },
  "tags": [
    {
      "name": "Meditations"
    },
    {
      "name": "Options"
    },
    {
      "name": "Meta"
    }
  ],
  "paths": {
    "/api/v1": {
      "get": {
        "operationId": "getApiIndex",
        "tags": [
          "Meta"
        ],
        "summary": "Get the API index with links to docs, OpenAPI and MCP.",
        "responses": {
          "200": {
            "description": "API index.",
            "headers": {
              "Access-Control-Allow-Origin": {
                "schema": {
                  "type": "string"
                },
                "description": "Always *."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiIndex"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/options": {
      "get": {
        "operationId": "listMeditationOptions",
        "tags": [
          "Options"
        ],
        "summary": "List every allowed value for meditation options (feelings, minutes, voices, styles, sounds).",
        "description": "Optional to call; createMeditation validates the same values and applies defaults.",
        "responses": {
          "200": {
            "description": "The option catalog.",
            "headers": {
              "Access-Control-Allow-Origin": {
                "schema": {
                  "type": "string"
                },
                "description": "Always *."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OptionsCatalog"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/meditations": {
      "post": {
        "operationId": "createMeditation",
        "tags": [
          "Meditations"
        ],
        "summary": "Create a personalized meditation and get a link the user opens to listen.",
        "description": "Provide an intention, a feeling, or both. Returns a link; the user opens it and presses Begin to start the audio, which is generated live. Rate limited per IP.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MeditationRequest"
              },
              "examples": {
                "intentionAndFeeling": {
                  "summary": "Anxious before an interview",
                  "value": {
                    "intention": "I can't stop thinking about tomorrow's interview",
                    "feeling": "anxious",
                    "minutes": 10
                  }
                },
                "sleep": {
                  "summary": "Wind down for sleep",
                  "value": {
                    "feeling": "tired",
                    "minutes": 20,
                    "time_of_day": "bedtime",
                    "voice": "sara",
                    "sound": "rain",
                    "style": "body-scan"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Meditation link created.",
            "headers": {
              "Access-Control-Allow-Origin": {
                "schema": {
                  "type": "string"
                },
                "description": "Always *."
              },
              "Location": {
                "schema": {
                  "type": "string",
                  "format": "uri"
                },
                "description": "The share URL."
              },
              "RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds until the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeditationCreated"
                },
                "example": {
                  "id": "k3Jx9QwA",
                  "url": "https://genmeditation.com/m/k3Jx9QwA",
                  "start_url": "https://genmeditation.com/start?intention=interview+tomorrow&feeling=anxious&minutes=10",
                  "summary": "10-minute guided meditation for feeling anxious",
                  "request": {
                    "intention": "I can't stop thinking about tomorrow's interview",
                    "feeling": "anxious",
                    "minutes": 10,
                    "time_of_day": null,
                    "voice": "mary",
                    "style": "auto",
                    "sound": "binaural",
                    "guidance": null
                  },
                  "created_at": "2026-01-01T09:00:00.000Z",
                  "instructions": "Open the url and press Begin. Audio is generated live when the listener starts."
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON or request body.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_request",
                    "message": "intention: Provide an intention, a feeling, or both"
                  }
                }
              }
            }
          },
          "413": {
            "description": "Body larger than 8 KB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "payload_too_large",
                    "message": "Request body must be 8 KB or smaller."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. Try again in about 5 minutes."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying."
              },
              "RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/meditations/{id}": {
      "get": {
        "operationId": "getMeditation",
        "tags": [
          "Meditations"
        ],
        "summary": "Get a meditation link by id, including its settings and play count.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The id returned by createMeditation (6 to 16 letters and digits).",
            "schema": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9]{6,16}$",
              "example": "k3Jx9QwA"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The meditation.",
            "headers": {
              "Access-Control-Allow-Origin": {
                "schema": {
                  "type": "string"
                },
                "description": "Always *."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Meditation"
                },
                "example": {
                  "id": "k3Jx9QwA",
                  "url": "https://genmeditation.com/m/k3Jx9QwA",
                  "start_url": "https://genmeditation.com/start?intention=interview+tomorrow&feeling=anxious&minutes=10",
                  "summary": "10-minute guided meditation for feeling anxious",
                  "request": {
                    "intention": "I can't stop thinking about tomorrow's interview",
                    "feeling": "anxious",
                    "minutes": 10,
                    "time_of_day": null,
                    "voice": "mary",
                    "style": "auto",
                    "sound": "binaural",
                    "guidance": null
                  },
                  "created_at": "2026-01-01T09:00:00.000Z",
                  "plays": 3
                }
              }
            }
          },
          "404": {
            "description": "No meditation with that id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Meditation not found."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Storage temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "storage_unavailable",
                    "message": "Lookup is temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "MeditationRequest": {
        "type": "object",
        "description": "At least one of intention or feeling is required.",
        "additionalProperties": false,
        "anyOf": [
          {
            "required": [
              "intention"
            ]
          },
          {
            "required": [
              "feeling"
            ]
          }
        ],
        "properties": {
          "intention": {
            "type": "string",
            "maxLength": 500,
            "description": "What the meditation should help with, in the user's own words (for example \"I can't stop thinking about tomorrow's interview\"). Up to 500 characters. Required unless feeling is given.",
            "example": "I can't stop thinking about tomorrow's interview"
          },
          "feeling": {
            "type": "string",
            "enum": [
              "anxious",
              "stressed",
              "tired",
              "unsettled",
              "scattered",
              "drained",
              "excited"
            ],
            "description": "How the user feels right now. Shapes tone and technique."
          },
          "minutes": {
            "type": "integer",
            "enum": [
              3,
              5,
              10,
              15,
              20,
              30
            ],
            "default": 10,
            "description": "Length in minutes. 5 or 10 suits most people; 15 to 30 for sleep."
          },
          "time_of_day": {
            "type": "string",
            "enum": [
              "morning",
              "midday",
              "evening",
              "bedtime"
            ],
            "description": "Optional. Defaults to the listener's local time when they press play, which also tunes pace (brighter in the morning, slower after 9 PM)."
          },
          "voice": {
            "type": "string",
            "enum": [
              "mary",
              "brad",
              "brittany",
              "sara"
            ],
            "default": "mary",
            "description": "Narrator voice. mary: warm, nurturing (US). brad: deep, grounding (US). brittany: clear (UK). sara: soft, ASMR-like (US)."
          },
          "style": {
            "type": "string",
            "enum": [
              "auto",
              "guided-journey",
              "awareness",
              "breathwork",
              "body-scan"
            ],
            "default": "auto",
            "description": "Technique. auto picks the best fit. guided-journey: imagery. awareness: mindfulness. breathwork: breathing patterns. body-scan: progressive relaxation."
          },
          "sound": {
            "type": "string",
            "enum": [
              "binaural",
              "waves",
              "rain",
              "wind"
            ],
            "default": "binaural",
            "description": "Background sound played under the voice."
          },
          "guidance": {
            "type": "string",
            "enum": [
              "minimal",
              "balanced",
              "continuous"
            ],
            "description": "How much talking versus silence. minimal: long silences. balanced: default. continuous: steady guidance."
          }
        }
      },
      "ResolvedRequest": {
        "type": "object",
        "description": "The request with defaults filled in.",
        "required": [
          "intention",
          "feeling",
          "minutes",
          "time_of_day",
          "voice",
          "style",
          "sound",
          "guidance"
        ],
        "properties": {
          "intention": {
            "type": "string",
            "maxLength": 500
          },
          "feeling": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "anxious",
              "stressed",
              "tired",
              "unsettled",
              "scattered",
              "drained",
              "excited"
            ],
            "description": "How the user feels right now. Shapes tone and technique."
          },
          "minutes": {
            "type": "integer",
            "enum": [
              3,
              5,
              10,
              15,
              20,
              30
            ],
            "default": 10,
            "description": "Length in minutes. 5 or 10 suits most people; 15 to 30 for sleep."
          },
          "time_of_day": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "morning",
              "midday",
              "evening",
              "bedtime"
            ],
            "description": "Optional. Defaults to the listener's local time when they press play, which also tunes pace (brighter in the morning, slower after 9 PM)."
          },
          "voice": {
            "type": "string",
            "enum": [
              "mary",
              "brad",
              "brittany",
              "sara"
            ],
            "default": "mary",
            "description": "Narrator voice. mary: warm, nurturing (US). brad: deep, grounding (US). brittany: clear (UK). sara: soft, ASMR-like (US)."
          },
          "style": {
            "type": "string",
            "enum": [
              "auto",
              "guided-journey",
              "awareness",
              "breathwork",
              "body-scan"
            ],
            "default": "auto",
            "description": "Technique. auto picks the best fit. guided-journey: imagery. awareness: mindfulness. breathwork: breathing patterns. body-scan: progressive relaxation."
          },
          "sound": {
            "type": "string",
            "enum": [
              "binaural",
              "waves",
              "rain",
              "wind"
            ],
            "default": "binaural",
            "description": "Background sound played under the voice."
          },
          "guidance": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "minimal",
              "balanced",
              "continuous"
            ],
            "description": "How much talking versus silence. minimal: long silences. balanced: default. continuous: steady guidance."
          }
        }
      },
      "MeditationCreated": {
        "type": "object",
        "required": [
          "id",
          "url",
          "start_url",
          "summary",
          "request",
          "created_at",
          "instructions"
        ],
        "properties": {
          "id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Link id, or null if storage was unavailable (the url is then a self-contained deep link)."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Give this to the user. They open it and press Begin."
          },
          "start_url": {
            "type": "string",
            "format": "uri",
            "description": "Self-contained deep link that works without storage."
          },
          "summary": {
            "type": "string",
            "description": "Human-readable one-liner, e.g. \"10-minute guided meditation for feeling anxious\"."
          },
          "request": {
            "$ref": "#/components/schemas/ResolvedRequest"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "instructions": {
            "type": "string"
          }
        }
      },
      "Meditation": {
        "type": "object",
        "required": [
          "id",
          "url",
          "start_url",
          "summary",
          "request",
          "plays",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "start_url": {
            "type": "string",
            "format": "uri"
          },
          "summary": {
            "type": "string"
          },
          "request": {
            "$ref": "#/components/schemas/ResolvedRequest"
          },
          "plays": {
            "type": "integer",
            "minimum": 0,
            "description": "How many times listeners have started it."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "OptionsCatalog": {
        "type": "object",
        "description": "Allowed values and defaults for every option.",
        "additionalProperties": true
      },
      "ApiIndex": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "docs": {
            "type": "string",
            "format": "uri"
          },
          "openapi": {
            "type": "string",
            "format": "uri"
          },
          "mcp": {
            "type": "string",
            "format": "uri"
          },
          "endpoints": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "description": "Stable machine-readable code."
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}