Integration Challenge and Solution with ChatGPT and Supernotes

I encountered challenges while integrating ChatGPT with Supernotes to automate card creation, primarily due to authentication issues. Initially, I tried using standard methods to send API requests from ChatGPT, but ran into errors, especially when using the “simple authentication” option in the GPT environment.

Solution: After some trial and error, I identified that the issue stemmed from the header name for the API key. The GPT environment defaults to using X-Api-Key, but Supernotes requires the header to be explicitly set as Api-Key using the “Custom” authentication option. Once I made this adjustment, the integration worked seamlessly.

This straightforward change allowed the automation process to function as intended.

For anyone facing similar issues, the key takeaway is to ensure the Api-Key header is properly configured.

Below is the working API schema that reflects the successful configuration:

openapi: 3.1.0
info:
  title: Supernotes API
  description: API for creating and managing notes in Supernotes.
  version: 1.0.0
servers:
  - url: https://api.supernotes.app/v1
    description: Supernotes API Server
paths:
  /cards/simple:
    post:
      operationId: createCard
      summary: Create a new note card
      description: This endpoint creates a new note card with the provided details.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCardRequest'
      responses:
        '200':
          description: A JSON object containing the details of the created note.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateCardResponse'
      security:
        - ApiKeyAuth: []  # This references the security scheme defined in the components section
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Api-Key  # API key will be automatically included in the header under 'Api-Key'
  schemas:
    CreateCardRequest:
      type: object
      properties:
        name:
          type: string
          description: The title of the note.
        markup:
          type: string
          description: The body content of the note in markup format.
        color:
          type: string
          description: The color associated with the note.
          enum:
            - blue
            - orange
            - red
            - green
        icon:
          type: string
          description: The icon representing the note.
      required:
        - name
        - markup
        - color
        - icon
    CreateCardResponse:
      type: object
      properties:
        data:
          type: object
          $ref: '#/components/schemas/CardData'
        membership:
          type: object
          $ref: '#/components/schemas/Membership'
        backlinks:
          type: array
          items:
            type: string
        parents:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Parent'
    CardData:
      type: object
      properties:
        id:
          type: string
        owner_id:
          type: string
        name:
          type: string
        markup:
          type: string
        html:
          type: string
        ydoc:
          type: string
        icon:
          type: string
        tags:
          type: array
          items:
            type: string
        color:
          type: string
        created_when:
          type: string
          format: date-time
        modified_when:
          type: string
          format: date-time
        modified_by_id:
          type: string
        synced_when:
          type: string
          format: date-time
        meta:
          type: object
        targeted_when:
          type: string
          format: date-time
        comment_count:
          type: integer
        likes:
          type: integer
        member_count:
          type: integer
        public_child_count:
          type: integer
    Membership:
      type: object
      properties:
        id:
          type: string
        liked:
          type: boolean
        personal_tags:
          type: array
          items:
            type: string
        personal_color:
          type: string
        perms:
          type: integer
        via_type:
          type: integer
        via_id:
          type: string
        created_when:
          type: string
          format: date-time
        modified_when:
          type: string
          format: date-time
        enrolled_when:
          type: string
          format: date-time
        opened_when:
          type: string
          format: date-time
        auto_publish_children:
          type: boolean
        view:
          type: object
          properties:
            display_type:
              type: integer
            sort_type:
              type: integer
            sort_ascending:
              type: boolean
        visibility:
          type: integer
        status:
          type: integer
        total_child_count:
          type: integer
    Parent:
      type: object
      properties:
        id:
          type: string
        owner_id:
          type: string
        parent_id:
          type: string
        child_id:
          type: string
        created_when:
          type: string
          format: date-time
        publishing_perms:
          type: integer
        archived:
          type: boolean
        parent_membership_status:
          type: integer
3 Likes