{"openapi":"3.1.0","info":{"title":"pnljournal API","version":"1.0.0","description":"Log, list and delete a user's trades, and read their strategies, in pnljournal, an agentic trading journal. Authenticate with the user's API key (created on the Account page). Agent guide: https://www.pnljournal.com/llms.txt. MCP server: https://www.pnljournal.com/api/mcp."},"servers":[{"url":"https://www.pnljournal.com/api/v1"}],"security":[{"apiKey":[]}],"paths":{"/me":{"get":{"operationId":"getMe","summary":"Who the API key belongs to","responses":{"200":{"description":"The key's owner","content":{"application/json":{"schema":{"type":"object","required":["email","time_zone"],"properties":{"email":{"type":"string","format":"email"},"time_zone":{"type":["string","null"],"description":"Saved IANA time zone, or null if none is saved."}}}}}},"401":{"$ref":"#/components/responses/Error"}}}},"/trades":{"get":{"operationId":"listTrades","summary":"List the trades that closed on a day","parameters":[{"name":"date","in":"query","required":false,"description":"Day as YYYY-MM-DD. Defaults to today in `time_zone`.","schema":{"type":"string","format":"date"}},{"name":"time_zone","in":"query","required":false,"description":"IANA time zone the day is measured in. Defaults to the user's saved zone, else UTC.","schema":{"type":"string","examples":["America/New_York"]}}],"responses":{"200":{"description":"The day's trades and total P&L per currency","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TradesDay"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"}}},"post":{"operationId":"logTrade","summary":"Log a closed trade","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NewTrade"}}}},"responses":{"201":{"description":"The saved trade","content":{"application/json":{"schema":{"type":"object","required":["trade"],"properties":{"trade":{"$ref":"#/components/schemas/Trade"}}}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"}}}},"/trades/{id}":{"delete":{"operationId":"deleteTrade","summary":"Delete one of the user's trades","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"204":{"description":"Deleted"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"}}}},"/strategies":{"get":{"operationId":"listStrategies","summary":"List the user's strategies, sorted by name","responses":{"200":{"description":"The user's strategies, without their text","content":{"application/json":{"schema":{"type":"object","required":["strategies"],"properties":{"strategies":{"type":"array","items":{"$ref":"#/components/schemas/StrategySummary"}}}}}}},"401":{"$ref":"#/components/responses/Error"}}}},"/strategies/{id}":{"get":{"operationId":"getStrategy","summary":"Get one of the user's strategies in full","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The strategy","content":{"application/json":{"schema":{"type":"object","required":["strategy"],"properties":{"strategy":{"$ref":"#/components/schemas/Strategy"}}}}}},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"}}}}},"components":{"securitySchemes":{"apiKey":{"type":"http","scheme":"bearer","description":"The user's API key, `pnl_…`, from the Account page."}},"responses":{"Error":{"description":"An error; `message` says what to fix","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"StrategySummary":{"type":"object","required":["id","name","updated_at"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","maxLength":100,"description":"Unique per user, ignoring case."},"updated_at":{"type":"string","format":"date-time"}}},"Strategy":{"type":"object","required":["id","name","body","created_at","updated_at"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","maxLength":100},"body":{"type":"string","maxLength":20000,"description":"How the user trades this setup, in their own words."},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"NewTrade":{"type":"object","required":["ticker","opened_at","closed_at","pnl"],"properties":{"ticker":{"type":"string","pattern":"^[A-Za-z0-9./^=-]{1,15}$","examples":["AAPL"]},"opened_at":{"type":"string","description":"ISO 8601. With a UTC offset it's exact; without one it's read in `time_zone`, else the user's saved zone.","examples":["2026-11-19T09:31:00-05:00"]},"closed_at":{"type":"string","description":"ISO 8601, same rules as opened_at. Not before opened_at, not in the future.","examples":["2026-11-19T10:02:00-05:00"]},"pnl":{"oneOf":[{"type":"number"},{"type":"string"}],"description":"Realized P&L in `pnl_currency`, negative for a loss. At most 2 decimals for USD, 9 for SOL (under 1,000,000 SOL).","examples":[125.5,-40,2.35]},"pnl_currency":{"type":"string","enum":["USD","SOL"],"default":"USD","description":"What `pnl` is denominated in."},"thesis":{"type":["string","null"],"maxLength":2000,"description":"Why the trader took the trade, in their own words. Blank is saved as null."},"time_zone":{"type":"string","description":"IANA time zone for times without an offset.","examples":["America/New_York"]}}},"Trade":{"type":"object","required":["id","ticker","opened_at","closed_at","pnl","pnl_currency","thesis"],"properties":{"id":{"type":"string","format":"uuid"},"ticker":{"type":"string"},"opened_at":{"type":"string","format":"date-time"},"closed_at":{"type":"string","format":"date-time"},"pnl":{"type":"number"},"pnl_currency":{"type":"string","enum":["USD","SOL"]},"thesis":{"type":["string","null"]}}},"TradesDay":{"type":"object","required":["date","time_zone","total_pnl","trades"],"properties":{"date":{"type":"string","format":"date"},"time_zone":{"type":"string"},"total_pnl":{"type":"object","description":"The day's total P&L in each currency. SOL isn't converted to dollars.","required":["USD","SOL"],"properties":{"USD":{"type":"number"},"SOL":{"type":"number"}}},"trades":{"type":"array","items":{"$ref":"#/components/schemas/Trade"}}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"}}}}}}}}