Ana içeriğe atla

Endpoint

POST /apiops/projects/{projectName}/connections/{connectionName}/

Authentication

Requires a Personal API Access Token.
Authorization: Bearer YOUR_TOKEN

Request

Headers

HeaderValueRequired
AuthorizationBearer Yes
Content-Typeapplication/jsonYes

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
connectionNamestringYesConnection name (must match name in body)

Request Body

Note: The API uses DTOs (Data Transfer Objects) for requests and responses. The type field is used as the discriminator field to identify the connection type, replacing the previous _class field used in internal entity models.

Full JSON Body Example (Email Connection)

{
  "type": "email",
  "name": "my-email-connection",
  "description": "Email connection for sending notifications",
  "deployToWorker": true,
  "enabled": true,
  "host": "smtp.gmail.com",
  "port": 587,
  "enableStartTls": true,
  "auth": true,
  "username": "[email protected]",
  "password": "app-password",
  "defaultEncoding": "UTF-8",
  "addressToTest": "[email protected]",
  "from": "[email protected]",
  "additionalProperties": []
}

Request Body Fields

Common Fields (All Connection Types)
FieldTypeRequiredDefaultDescription
typestringYes-Connection type discriminator field. Used to identify the connection type in API requests/responses. Valid values: email, kafka, elasticsearch, database, ldap, ftp, rabbitMq, activeMq, snmp, linux-script, graylog, syslog, webhook, logback
namestringYes-Connection name (must match path parameter)
descriptionstringNo-Connection description
deployToWorkerbooleanNotrueWhether to deploy to worker
enabledbooleanNotrueWhether connection is enabled

Connection Types

  • email - Email (SMTP) connection
  • kafka - Kafka connection
  • elasticsearch - Elasticsearch connection
  • database - Database connection
  • ldap - LDAP connection
  • ftp - FTP connection
  • rabbitMq - RabbitMQ connection
  • activeMq - Apache ActiveMQ connection
  • snmp - SNMP connection
  • linux-script - Linux Script connection
  • ops-genie - OpsGenie connection (if available)
  • graylog - Graylog connection
  • syslog - Syslog connection
  • webhook - Webhook connection
  • logback - Logback connection
Note: Connection-specific fields vary by connection type. See individual connection type documentation for complete field descriptions:

Response

Success Response (200 OK)

{
  "success": true,
  "deploymentResult": {
    "success": true
  }
}

Response Fields

FieldTypeDescription
successbooleanIndicates if the request was successful
deploymentResultobjectDeployment result (if deployToWorker=true)
deploymentResult.successbooleanDeployment success

Error Response (400 Bad Request)

{
  "error": "bad_request",
  "error_description": "Connection (name: my-email-connection) already exists!"
}

Common Causes

  • Connection name already exists
  • Connection name in path does not match name in body
  • Invalid connection type
  • Missing required fields for connection type
  • Invalid field values

Error Response (401 Unauthorized)

{
  "error": "unauthorized_client",
  "error_description": "Invalid token"
}

Error Response (404 Not Found)

{
  "error": "not_found",
  "error_description": "Project 'MyProject' not found"
}

cURL Example

Example 1: Create Email Connection

curl -X POST \
  "https://demo.apinizer.com/apiops/projects/MyProject/connections/my-email-connection/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "email",
    "name": "my-email-connection",
    "description": "Email connection for sending notifications",
    "deployToWorker": true,
    "enabled": true,
    "host": "smtp.gmail.com",
    "port": 587,
    "enableStartTls": true,
    "auth": true,
    "username": "[email protected]",
    "password": "app-password",
    "defaultEncoding": "UTF-8",
    "from": "[email protected]"
  }'

Example 2: Create Database Connection

curl -X POST \
  "https://demo.apinizer.com/apiops/projects/MyProject/connections/my-db-connection/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "database",
    "name": "my-db-connection",
    "description": "PostgreSQL database connection",
    "deployToWorker": true,
    "enabled": true,
    "host": "localhost",
    "port": 5432,
    "databaseName": "mydb",
    "username": "dbuser",
    "password": "dbpassword",
    "driverClassName": "org.postgresql.Driver",
    "jdbcUrl": "jdbc:postgresql://localhost:5432/mydb"
  }'

Example 3: Create Kafka Connection

curl -X POST \
  "https://demo.apinizer.com/apiops/projects/MyProject/connections/my-kafka-connection/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "kafka",
    "name": "my-kafka-connection",
    "description": "Kafka connection for event streaming",
    "deployToWorker": true,
    "enabled": true,
    "topicName": "events",
    "bootstrapServers": "localhost:9092",
    "keyStoreName": "my-keystore",
    "trustStoreName": "my-truststore"
  }'

Permissions

  • User must have CONNECTIONS + MANAGE permission in the project

Notes and Warnings

  • Name Matching: Connection name in path parameter must match the name field in the request body (case-insensitive)
  • Unique Names: Connection names must be unique within a project
  • Secret Fields: Never commit connection configurations with secrets to version control
  • Connection Types: Each connection type has different required fields. See individual connection type documentation for details
  • Deployment: If deployToWorker: true, connection is automatically deployed to workers
  • References: Some connection types support references to certificates or keystores by name (e.g., keyStoreName, trustStoreName)