Skip to main content

Connect a mailbox via OAuth 2.0

Connect a new Google or Microsoft mailbox, or reconnect an existing one, by generating an authorization link for the mailbox owner. The owner opens the link in a browser and signs in with the specified address to authorize the connection to Woodpecker. Woodpecker handles the OAuth callback and starts the connection or reconnection process.

To connect mailboxes using SMTP/IMAP credentials instead, use the bulk connection endpoint.

Request​

You can repeat the request with the same account, provider, and email address to generate a new authorization link and reconnect a disconnected mailbox.

Endpoint​

POST https://api.woodpecker.co/rest/v2/mailboxes/oauth2/register

Headers​

x-api-key: {YOUR_API_KEY}
Content-Type: application/json

For details on how to authenticate your requests, please see the authentication guide.

Body​

{
"provider": "GOOGLE",
"email": "mailbox@example.com"
}

Body schema​

FieldTypeRequiredDescription
providerstringYesMailbox provider. Use GOOGLE or MICROSOFT, with matching capitalization
emailstringYesEmail address of the mailbox that will be connected to Woodpecker

Request samples​

curl --request POST \
--url "https://api.woodpecker.co/rest/v2/mailboxes/oauth2/register" \
--header "x-api-key: {YOUR_API_KEY}" \
--header "Content-Type: application/json" \
--data '{
"provider": "GOOGLE",
"email": "mailbox@example.com"
}'

Response​

Response examples​

Pass the returned link to the mailbox owner and poll with the same payload until the status is CONNECTED, AUTHORIZATION_ERROR, or CONNECTION_ERROR. Check OAuth 2.0 mailbox connection status.

{
"login_url": "https://accounts.example.com/oauth2/authorize"
}

Body schema​

FieldTypeDescription
login_urlstringAuthorization URL for the mailbox