Skip to main content
AfterCare’s Google Drive integration lets you pull discharge paperwork directly from your Drive and push your generated recovery guide back as a JSON backup. The integration uses Google’s drive.file OAuth scope, which grants AfterCare access only to files it creates or that the user explicitly selects — no broader access to your Drive. Follow the steps below to connect Drive before calling the import or backup endpoints.
The POST /drive/import and POST /drive/backup endpoints currently return 503 Service Unavailable until the Google OAuth configuration is fully provisioned in this environment. Check GET /drive/status to confirm the integration is active before calling them.

Connect Google Drive


Endpoint reference

GET /drive/status

Return the current Google Drive connection status for the authenticated user.
cURL

Response — 200 OK

Example response

POST /drive/auth

Start the drive.file OAuth authorization flow and return the Google consent URL.
cURL

Response — 200 OK

Example response
Redirect the user to authUrl to show the Google consent screen. The state value is signed by AfterCare and validated when the callback arrives — do not modify it.

GET /drive/callback

Complete the OAuth flow after Google redirects the user back with an authorization code. AfterCare calls this endpoint internally as part of the redirect — your app does not call it directly.
GET /drive/callback is AfterCare’s OAuth redirect URI — your application never calls it directly. Once Google redirects the user here, AfterCare exchanges the authorization code for an access token and marks Drive as connected. The state parameter is validated on every callback to prevent CSRF attacks.

Query parameters


POST /drive/import

Import a file from the connected Google Drive and queue it for processing as a discharge document. If the same file has been imported before, the endpoint returns the existing document instead of creating a duplicate.
string
required
The Google Drive file ID of the document to import. The file must be accessible to the OAuth token on record for the authenticated user.

Response — 202 Accepted

New document
Duplicate detected
When deduplicated is true, the file was already imported and the existing document is returned. No new processing is queued.

POST /drive/backup

Back up a recovery guide to the connected Google Drive as a formatted JSON file named recovery-guide-{documentId}.json.
string (UUID)
required
The UUID of the document whose recovery plan you want to back up. The document must belong to the authenticated user and must have a completed recovery plan (status: "ready").

Response — 201 Created

Example response

Response — 404 Not Found

Returned when the document does not exist, does not belong to the authenticated user, or does not yet have a completed recovery plan.

Upload documents

Upload a discharge document directly from your device instead of importing from Drive.

Ask a question

Ask a natural-language question grounded in any uploaded or imported document.