Skip to main content
Credal | Documentation

Search documentation

Type to search this documentation.

On this pageOverview

Update Mongo Collection Sync

POST https://api.credal.ai/api/v0/documentCollections/mongodb/updateMongoSync Content-Type: application/json

Credal lets you easily sync your MongoDB data for use in Collections and Agents. Update an existing sync from a MongoDB collection to a Credal collection via the mongoCredentialId, to disambiguate between multiple potential syncs to a given collection.

Reference: https://docs.credal.ai/api-reference/api-reference/document-collections/update-mongo-collection-sync

  • Authorization header (bearer token, required) — Bearer authentication of the form Bearer <token>, where token is your auth token.

This endpoint expects an object.

  • mongoCredentialId (UUID, required)
  • mongoURI (string, required)
  • config (MongoCollectionSyncConfig, required)
  • mongoCredentialId (UUID, required)
  • resourceId (string, required)
  • syncLaunched (boolean, required)
  • syncName (string, required)
  • collectionName (string, required)
  • filterExpression (any, required)
  • sourceFields (MongoSourceFieldsConfig, required)
  • body (string, required)
  • sourceName (string, required)
  • sourceSystemUpdated (string, optional)
  • sourceUrl (string, optional)

Request

JSON
{
  "mongoCredentialId": "5988ed76-6ee1-11ef-97dd-1fca54b7c4bc",
  "mongoURI": "mongodb+srv://cluster0.abcdefg.mongodb.net/Cluster0?retryWrites=true&w=majority",
  "config": {
    "syncName": "My recent summarized sales transcripts",
    "collectionName": "myCollection",
    "filterExpression": {
      "transcriptDatetime": {
        "$gt": "2023-01-01T00:00:00.000Z"
      }
    },
    "sourceFields": {
      "body": "transcriptSummary",
      "sourceName": "meetingName",
      "sourceSystemUpdated": "transcriptDatetime",
      "sourceUrl": "link"
    }
  }
}

Response

JSON
{
  "mongoCredentialId": "5988ed76-6ee1-11ef-97dd-1fca54b7c4bc",
  "resourceId": "mongo-collection-credal-sync-bfd82450-6c68-11ef-bb2b-f7176fe2f3c4",
  "syncLaunched": true
}

SDK Code

Example0
import { CredalClient } from "@credal/sdk";

async function main() {
    const client = new CredalClient({
        apiKey: "YOUR_TOKEN_HERE",
    });
    await client.documentCollections.updateMongoCollectionSync({
        mongoCredentialId: "5988ed76-6ee1-11ef-97dd-1fca54b7c4bc",
        mongoUri: "mongodb+srv://cluster0.abcdefg.mongodb.net/Cluster0?retryWrites=true&w=majority",
        config: {
            syncName: "My recent summarized sales transcripts",
            collectionName: "myCollection",
            filterExpression: {
                transcriptDatetime: {
                    $gt: "2023-01-01T00:00:00.000Z",
                },
            },
            sourceFields: {
                body: "transcriptSummary",
                sourceName: "meetingName",
                sourceSystemUpdated: "transcriptDatetime",
                sourceUrl: "link",
            },
        },
    });
}
main();
Example0
from credal import CredalV0
import uuid
from credal.document_collections import MongoCollectionSyncConfig, MongoSourceFieldsConfig

client = CredalV0(
    api_key="YOUR_TOKEN_HERE",
)

client.document_collections.update_mongo_collection_sync(
    mongo_credential_id=uuid.UUID("5988ed76-6ee1-11ef-97dd-1fca54b7c4bc"),
    mongo_uri="mongodb+srv://cluster0.abcdefg.mongodb.net/Cluster0?retryWrites=true&w=majority",
    config=MongoCollectionSyncConfig(
        sync_name="My recent summarized sales transcripts",
        collection_name="myCollection",
        filter_expression={"transcriptDatetime": {"$gt": "2023-01-01T00:00:00.000Z"}},
        source_fields=MongoSourceFieldsConfig(
            body="transcriptSummary",
            source_name="meetingName",
            source_system_updated="transcriptDatetime",
            source_url="link",
        ),
    ),
)
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu