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

# Generate an article

> If an article already exists, returns it for 1 credit (200). Otherwise reserves 100 credits and starts generation (202). Poll the job for the included result. Failed or cancelled jobs are refunded. Replays of the same idempotency key return the original operation without another charge.



## OpenAPI

````yaml POST /api/v1/articles
openapi: 3.1.0
info:
  title: YCpedia API
  version: 1.0.0
  description: >-
    Read, generate, and update profile articles by LinkedIn ID. Obtain your API
    key and API base URL from the YCpedia team.
servers:
  - url: https://api.thealmanac.ai
    description: Production API
security:
  - CustomerApiKey: []
paths:
  /api/v1/articles:
    post:
      summary: Generate an article
      description: >-
        If an article already exists, returns it for 1 credit (200). Otherwise
        reserves 100 credits and starts generation (202). Poll the job for the
        included result. Failed or cancelled jobs are refunded. Replays of the
        same idempotency key return the original operation without another
        charge.
      operationId: generate_an_article
      parameters:
        - name: Idempotency-Key
          in: header
          required: true
          description: >-
            A unique value for this operation. Reuse it when retrying the same
            request to avoid duplicate charges.
          schema:
            type: string
            minLength: 1
            maxLength: 200
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiProfileRequest'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/ApiReadResponse'
                  - $ref: '#/components/schemas/ApiJobResponse'
        '202':
          description: Generation queued or running. Poll the returned job_id for free.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiJobResponse'
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: array
                        items:
                          additionalProperties: true
                          type: object
                required:
                  - detail
        '402':
          description: Insufficient credits. Buy credits before retrying.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: array
                        items:
                          additionalProperties: true
                          type: object
                required:
                  - detail
        '404':
          description: Profile or job not found, unavailable, or inaccessible.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: array
                        items:
                          additionalProperties: true
                          type: object
                required:
                  - detail
        '409':
          description: >-
            Another job is active for this profile, or the idempotency key was
            used for a different operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: array
                        items:
                          additionalProperties: true
                          type: object
                required:
                  - detail
        '422':
          description: Invalid request or missing Idempotency-Key.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: array
                        items:
                          additionalProperties: true
                          type: object
                required:
                  - detail
        '429':
          description: Rate limit exceeded. Wait for the Retry-After duration.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: array
                        items:
                          additionalProperties: true
                          type: object
                required:
                  - detail
          headers:
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
                example: 60
      security:
        - CustomerApiKey: []
components:
  schemas:
    ApiProfileRequest:
      additionalProperties: false
      properties:
        linkedin_id:
          maxLength: 200
          minLength: 1
          title: Linkedin Id
          type: string
          examples:
            - jane-doe
      required:
        - linkedin_id
      title: ApiProfileRequest
      type: object
    ApiReadResponse:
      properties:
        article:
          $ref: '#/components/schemas/ApiArticle'
        credits_charged:
          title: Credits Charged
          type: integer
          description: Credits charged for this article read.
          examples:
            - 1
      required:
        - article
        - credits_charged
      title: ApiReadResponse
      type: object
    ApiJobResponse:
      properties:
        job_id:
          format: uuid
          title: Job Id
          type: string
        linkedin_id:
          title: Linkedin Id
          type: string
          examples:
            - jane-doe
        status:
          enum:
            - queued
            - running
            - succeeded
            - failed
            - cancelled
          title: Status
          type: string
        credits_charged:
          title: Credits Charged
          type: integer
          description: >-
            Credits reserved or charged for this operation. Returns 0 after a
            failed or cancelled job is refunded.
          examples:
            - 100
        article:
          anyOf:
            - $ref: '#/components/schemas/ApiArticle'
            - type: 'null'
          default: null
        error:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Error
      required:
        - job_id
        - linkedin_id
        - status
        - credits_charged
      title: ApiJobResponse
      type: object
    ApiArticle:
      properties:
        article_id:
          title: Article Id
          type: string
        title:
          title: Title
          type: string
        content:
          title: Content
          type: string
          description: Article text with its original formatting and citation references.
        sources:
          items:
            $ref: '#/components/schemas/ApiSource'
          title: Sources
          type: array
        infobox:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Infobox
          description: Available profile metadata. Keys vary by article; may be null.
        current_version:
          title: Current Version
          type: integer
          examples:
            - 1
        created_at:
          format: date-time
          title: Created At
          type: string
        updated_at:
          format: date-time
          title: Updated At
          type: string
      required:
        - article_id
        - title
        - content
        - sources
        - infobox
        - current_version
        - created_at
        - updated_at
      title: ApiArticle
      type: object
    ApiSource:
      properties:
        id:
          title: Id
          type: integer
        title:
          title: Title
          type: string
        url:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Url
        publication:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Publication
        excerpt:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Excerpt
      required:
        - id
        - title
      title: ApiSource
      type: object
  securitySchemes:
    CustomerApiKey:
      type: http
      scheme: bearer
      description: Your customer API key (alm_…). Keep it on your server.

````