Skip to content
Rigel docs
Open Rigel

Choose which Gmail mail Rigel reads

email.connection.set_filter

POST/api/v1/households/{household_id}/commands/email.connection.set_filter

  • Command
  • Rigel runs it
  • Applies offline

Sets the Gmail labels and sender addresses or domains whose mail Rigel reads from a connected Gmail account; mail that matches neither is never read. Creates the connection the first time and replaces the filter after that. At least one label or sender is required. Fails with integration_not_found, or wrong_service when the integration isn't Gmail.

Parameters#

Choose which Gmail mail Rigel reads: parameters
FieldDescription
household_idpathstringrequired

The household's ID.

Idempotency-Keyheaderstringoptional

The command's ID. Reuse it when retrying the same command.

Request body#

JSON, as application/json.

Choose which Gmail mail Rigel reads: request body fields
FieldDescription
integration_idstringrequired

The connected Gmail account.

labelsarray of stringsrequired

Gmail labels to read, up to 20. Can be empty if senders is not.

at most 20 items
sendersarray of stringsrequired

Sender addresses or domains to read, up to 20. Can be empty if labels is not.

at most 20 items

Response#

200 The command was applied.

Choose which Gmail mail Rigel reads: response fields
FieldDescription
resultobjectrequired

What the command returned, such as the IDs it created.

result.email_connection_idstringrequired

The connection that was created or changed.

versionintegerrequired

The household version after the command.

Errors#

Every error has the same envelope: error.code, error.message, error.details, error.recovery and error.request_id.

Choose which Gmail mail Rigel reads: errors
StatusCodeWhen
400validation_failedA field is missing, misspelled or out of range. details.fields lists each problem.
401unauthenticatedThe request has no valid session.
404integration_not_foundAn integration that isn't there is refused.
404not_foundThe household doesn't exist, or you aren't a member of it.
409wrong_serviceOnly Gmail can be read.
409idempotency_key_reusedThe Idempotency-Key was already used for a different command.

Examples#

These are real. Each scenario is one of the command's test cases, run on a household when this site was built, and the response is what the API returned.

Creates the connection and its rules the first time

Request, curl
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter' \
  -H "Cookie: rigel_session=$RIGEL_SESSION" \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
  -d '{
  "integration_id": "int_01JC0000000000000000000001",
  "labels": [
    "Rigel",
    "Quotes"
  ],
  "senders": [
    "smithhvac.example"
  ]
}'
Request, TypeScript
const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
    Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
  },
  body: JSON.stringify({
    integration_id: "int_01JC0000000000000000000001",
    labels: [
      "Rigel",
      "Quotes",
    ],
    senders: [
      "smithhvac.example",
    ],
  }),
});
const data = await response.json();
Request, HTTP
POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA

{
  "integration_id": "int_01JC0000000000000000000001",
  "labels": [
    "Rigel",
    "Quotes"
  ],
  "senders": [
    "smithhvac.example"
  ]
}
Response, 200
HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0QH5HDR9PNPA890N3

{
  "result": {
    "email_connection_id": "emc_01JC4N0000MBGE5RJ6Q7V6V6T8"
  },
  "version": 1
}

Senders alone are enough, and repeats count once

Request, curl
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter' \
  -H "Cookie: rigel_session=$RIGEL_SESSION" \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
  -d '{
  "integration_id": "int_01JC0000000000000000000001",
  "labels": [],
  "senders": [
    "kim@example.com",
    "kim@example.com"
  ]
}'
Request, TypeScript
const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
    Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
  },
  body: JSON.stringify({
    integration_id: "int_01JC0000000000000000000001",
    labels: [],
    senders: [
      "kim@example.com",
      "kim@example.com",
    ],
  }),
});
const data = await response.json();
Request, HTTP
POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA

{
  "integration_id": "int_01JC0000000000000000000001",
  "labels": [],
  "senders": [
    "kim@example.com",
    "kim@example.com"
  ]
}
Response, 200
HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0PHF60554XR02CF0X

{
  "result": {
    "email_connection_id": "emc_01JC4N0000MBGE5RJ6Q7V6V6T8"
  },
  "version": 1
}

Replaces the rules, keeps the ones that stay, and clears the problem

Request, curl
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter' \
  -H "Cookie: rigel_session=$RIGEL_SESSION" \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
  -d '{
  "integration_id": "int_01JC0000000000000000000001",
  "labels": [
    "Keep",
    "New"
  ],
  "senders": []
}'
Request, TypeScript
const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
    Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
  },
  body: JSON.stringify({
    integration_id: "int_01JC0000000000000000000001",
    labels: [
      "Keep",
      "New",
    ],
    senders: [],
  }),
});
const data = await response.json();
Request, HTTP
POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA

{
  "integration_id": "int_01JC0000000000000000000001",
  "labels": [
    "Keep",
    "New"
  ],
  "senders": []
}
Response, 200
HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0XA5HWKKFEP82J1TH

{
  "result": {
    "email_connection_id": "emc_01JC0000000000000000000001"
  },
  "version": 1
}

An integration that isn't there is refused

Request, curl
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter' \
  -H "Cookie: rigel_session=$RIGEL_SESSION" \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
  -d '{
  "integration_id": "int_01JC0000000000000000000001",
  "labels": [
    "x"
  ],
  "senders": []
}'
Request, TypeScript
const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
    Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
  },
  body: JSON.stringify({
    integration_id: "int_01JC0000000000000000000001",
    labels: [
      "x",
    ],
    senders: [],
  }),
});
const data = await response.json();
Request, HTTP
POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA

{
  "integration_id": "int_01JC0000000000000000000001",
  "labels": [
    "x"
  ],
  "senders": []
}
Response, 404
HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0QDP1F2S3Q06BATT3

{
  "error": {
    "code": "integration_not_found",
    "message": "That account isn't connected any more. No changes were applied.",
    "details": {},
    "recovery": "Read the current state, then send a command that fits it.",
    "request_id": "req_01K9D9S2R0QDP1F2S3Q06BATT3"
  }
}

Only Gmail can be read

Request, curl
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter' \
  -H "Cookie: rigel_session=$RIGEL_SESSION" \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
  -d '{
  "integration_id": "int_01JC0000000000000000000001",
  "labels": [
    "x"
  ],
  "senders": []
}'
Request, TypeScript
const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
    Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
  },
  body: JSON.stringify({
    integration_id: "int_01JC0000000000000000000001",
    labels: [
      "x",
    ],
    senders: [],
  }),
});
const data = await response.json();
Request, HTTP
POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.connection.set_filter HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA

{
  "integration_id": "int_01JC0000000000000000000001",
  "labels": [
    "x"
  ],
  "senders": []
}
Response, 409
HTTP/1.1 409 Conflict
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0F40TBCKBA4MXPG7H

{
  "error": {
    "code": "wrong_service",
    "message": "Only a connected Gmail account can be read this way. No changes were applied.",
    "details": {
      "service": "google_calendar"
    },
    "recovery": "Read the current state, then send a command that fits it.",
    "request_id": "req_01K9D9S2R0F40TBCKBA4MXPG7H"
  }
}

For Rigel#

Rigel's tool for this command is email_connection_set_filter. Rigel runs this on its own, then says what it did. The agent guide has the rest.

Rigel is in early access, and sign-up is by invitation. Open Rigel