Criar um acionador

POSTAR /groups/{groupId}/apps/{appId}/triggers

Crie um novo acionador no seu aplicativo.

parâmetros de caminho

aplicação/json

corpo, corpo objeto Obrigatório

Uma configuração para um trigger de banco de dados, agendado ou de autenticação.

Um dos seguintes:

Respostas

  • 201 aplicação/json

    Criado com sucesso.

    Um dos seguintes:
POST /groups/{groupId}/apps/{appId}/triggers
curl \
 --request POST 'https://services.cloud.mongodb.com/api/admin/v3.0/groups/{groupId}/apps/{appId}/triggers' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{"name":"onNewEmployee","type":"DATABASE","config":{"match":{},"project":{},"database":"HR","collection":"employees","service_id":"5adeb649b8b998486770ae7c","full_document":true,"operation_types":["INSERT"]},"function_id":"5eea9ca4ca0e356e2c2a148a","event_processors":{"FUNCTION":{"config":{"function_id":"6841b8d3e71dc81bed89dbba","function_name":"Atlas_Triggers_DatabaseInsert_1749137618"}}}}'
Exemplos de solicitação
{
  "name": "onNewEmployee",
  "type": "DATABASE",
  "config": {
    "match": {},
    "project": {},
    "database": "HR",
    "collection": "employees",
    "service_id": "5adeb649b8b998486770ae7c",
    "full_document": true,
    "operation_types": [
      "INSERT"
    ]
  },
  "function_id": "5eea9ca4ca0e356e2c2a148a",
  "event_processors": {
    "FUNCTION": {
      "config": {
        "function_id": "6841b8d3e71dc81bed89dbba",
        "function_name": "Atlas_Triggers_DatabaseInsert_1749137618"
      }
    }
  }
}
{
  "name": "onNewApiKey",
  "type": "AUTHENTICATION",
  "config": {
    "providers": [
      "api-key"
    ],
    "operation_type": "CREATE"
  },
  "function_id": "5eea9ca4ca0e356e2c2a148a",
  "event_processors": {
    "FUNCTION": {
      "config": {
        "function_id": "6841b8d3e71dc81bed89dbba",
        "function_name": "Atlas_Triggers_Auth_Create_1749137618"
      }
    }
  }
}
{
  "name": "createDailyReport",
  "type": "SCHEDULED",
  "config": {
    "schedule": "0 8 * * *"
  },
  "function_id": "5eea9ca4ca0e356e2c2a148a",
  "event_processors": {
    "FUNCTION": {
      "config": {
        "function_id": "6841b8d3e71dc81bed89dbba",
        "function_name": "Atlas_Triggers_Monthly_1749137618"
      }
    }
  }
}
Exemplos de resposta (201)
{
  "name": "onNewEmployee",
  "type": "DATABASE",
  "config": {
    "match": {},
    "project": {},
    "database": "HR",
    "collection": "employees",
    "service_id": "5adeb649b8b998486770ae7c",
    "full_document": true,
    "operation_types": [
      "INSERT"
    ]
  },
  "function_id": "5eea9ca4ca0e356e2c2a148a",
  "event_processors": {
    "FUNCTION": {
      "config": {
        "function_id": "6841b8d3e71dc81bed89dbba",
        "function_name": "Atlas_Triggers_DatabaseInsert_1749137618"
      }
    }
  }
}
{
  "name": "onNewApiKey",
  "type": "AUTHENTICATION",
  "config": {
    "providers": [
      "api-key"
    ],
    "operation_type": "CREATE"
  },
  "function_id": "5eea9ca4ca0e356e2c2a148a",
  "event_processors": {
    "FUNCTION": {
      "config": {
        "function_id": "6841b8d3e71dc81bed89dbba",
        "function_name": "Atlas_Triggers_Auth_Create_1749137618"
      }
    }
  }
}
{
  "name": "createDailyReport",
  "type": "SCHEDULED",
  "config": {
    "schedule": "0 8 * * *"
  },
  "function_id": "5eea9ca4ca0e356e2c2a148a",
  "event_processors": {
    "FUNCTION": {
      "config": {
        "function_id": "6841b8d3e71dc81bed89dbba",
        "function_name": "Atlas_Triggers_Monthly_1749137618"
      }
    }
  }
}