{
  "openapi": "3.0.0",
  "info": {
    "version": "0.1.0",
    "title": "reflect",
    "license": {
      "name": "MIT"
    },
    "description": "This API is for the note-taking app Reflect.\n\nIt supports appending data to your notes, returning a list of the links you've bookmarked, and a few other things.\n\nWe don't have any official bindings, we suggest just making https requests in your language of choice.\n\n## Append-only\n\nYou'll notice that all of the note-related endpoints are write-only (well, to be precise, they're append only). This is because your notes contents are end-to-end encrypted. Our servers can't read the contents of your notes, so we can't serve them up in the API.\n\n## OAuth authentication\n\nFor authentication, we support OAuth. You will need to create credentials here (https://reflect.app/developer/oauth). You'll have to do this even if you are only building a client for yourself. We do, however, support generating an access token from that interface - which essentially equivalent to an API key.\n\nWe do support OAuth's PKCE extension (https://auth0.com/docs/get-started/authentication-and-authorization-flow/call-your-api-using-the-authorization-code-flow-with-pkce) which means you can build a client to Reflect without shipping secret keys around.\n\nYou will need to pass the access token you get along with every API request, like this:\n\ncurl 'https://reflect.app/api/graphs' -H 'Authorization: Bearer YOUR_ACCESS_TOKEN'\n"
  },
  "servers": [
    {
      "url": "https://reflect.app/api"
    }
  ],
  "paths": {
    "/graphs": {
      "get": {
        "description": "Returns all graphs",
        "responses": {
          "200": {
            "description": "A list of graphs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Graph"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "reflect_auth": [
              "read:graph"
            ]
          }
        ]
      }
    },
    "/graphs/{graphId}/books": {
      "get": {
        "description": "Returns all books",
        "parameters": [
          {
            "in": "path",
            "name": "graphId",
            "required": true,
            "description": "Your graph identifier",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A list of books",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Book"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "reflect_auth": [
              "write:graph",
              "read:graph"
            ]
          }
        ]
      }
    },
    "/graphs/{graphId}/links": {
      "get": {
        "description": "Returns all links",
        "parameters": [
          {
            "in": "path",
            "name": "graphId",
            "required": true,
            "description": "Your graph identifier",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A list of links",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Link"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "reflect_auth": [
              "read:graph"
            ]
          }
        ]
      },
      "post": {
        "description": "Create a new link",
        "parameters": [
          {
            "in": "path",
            "name": "graphId",
            "required": true,
            "description": "Your graph identifier",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "$ref": "#/components/requestBodies/Link"
        },
        "responses": {
          "200": {
            "description": "Your created link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Link"
                }
              }
            }
          }
        },
        "security": [
          {
            "reflect_auth": [
              "write:graph",
              "read:graph"
            ]
          }
        ]
      }
    },
    "/graphs/{graphId}/daily-notes": {
      "put": {
        "description": "Appends to daily note",
        "parameters": [
          {
            "in": "path",
            "name": "graphId",
            "required": true,
            "description": "Your graph identifier",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "text",
                  "transform_type"
                ],
                "properties": {
                  "date": {
                    "description": "Date of the daily note. ISO 8601 format. Defaults to today.",
                    "type": "string",
                    "example": "2020-01-01"
                  },
                  "text": {
                    "description": "Text to append to the daily note",
                    "type": "string"
                  },
                  "transform_type": {
                    "description": "Transform type to apply to the text. This will always be list-append for now.",
                    "type": "string",
                    "enum": [
                      "list-append"
                    ],
                    "example": "list-append"
                  },
                  "list_name": {
                    "description": "Name of the list to append to. To backlink, use the format [[List Name]].",
                    "type": "string",
                    "example": "Updates"
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Success message",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "reflect_auth": [
              "write:graph"
            ]
          }
        ]
      }
    },
    "/graphs/{graphId}/notes": {
      "post": {
        "description": "Creates a new note",
        "parameters": [
          {
            "in": "path",
            "name": "graphId",
            "required": true,
            "description": "Your graph identifier",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "subject",
                  "content_markdown"
                ],
                "properties": {
                  "subject": {
                    "description": "The subject of the note",
                    "type": "string"
                  },
                  "content_markdown": {
                    "description": "The content of the note in markdown",
                    "type": "string"
                  },
                  "pinned": {
                    "description": "Whether the note should be pinned",
                    "type": "boolean",
                    "default": false
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Success message",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "reflect_auth": [
              "write:graph"
            ]
          }
        ]
      }
    },
    "/users/me": {
      "get": {
        "description": "Returns current user",
        "responses": {
          "200": {
            "description": "Current user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                }
              }
            }
          }
        },
        "security": [
          {
            "reflect_auth": [
              "read:graph",
              "write:graph"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "requestBodies": {
      "BookArray": {
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "books": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Book"
                  }
                }
              }
            }
          }
        },
        "description": "List of book objects",
        "required": true
      },
      "Link": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Link"
            }
          }
        },
        "description": "Link object",
        "required": true
      }
    },
    "schemas": {
      "Book": {
        "required": [
          "id",
          "asin",
          "title"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "asin": {
            "type": "string",
            "description": "Amazon Standard Identification Number"
          },
          "title": {
            "type": "string",
            "description": "Book title"
          },
          "authors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Array of book author names"
          },
          "notes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BookNote"
            },
            "description": "Array of book notes"
          }
        }
      },
      "BookNote": {
        "required": [
          "type"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "note",
              "highlight"
            ],
            "description": "Type of note"
          },
          "page": {
            "type": "integer",
            "format": "int32",
            "description": "Page number of note (if applicable)"
          },
          "location": {
            "type": "integer",
            "format": "int32",
            "description": "Location of note (if applicable)"
          },
          "value": {
            "type": "string",
            "description": "Note contents"
          }
        }
      },
      "User": {
        "required": [
          "uid"
        ],
        "properties": {
          "uid": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "graph_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Link": {
        "required": [
          "url"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "highlights": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Graph": {
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      }
    },
    "securitySchemes": {
      "reflect_auth": {
        "description": "Reflect OAuth",
        "type": "oauth2",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://reflect.app/oauth",
            "tokenUrl": "https://reflect.app/api/oauth/token",
            "scopes": {
              "read:graph": "Read access to protected resources",
              "write:graph": "Write access to protected resources"
            }
          }
        }
      }
    }
  }
}