• DATA
  • ADMIN
  • TEST
  • HUMAN

How to run anonymous Apex code with your agent

Connect your AI client to Salesforce once. From then on, you can execute scripts to fix data or manage settings directly from your chat window.

Ask AI about this page

Our technology reaches across leading technology and enterprise teams.

  • Amazon
  • NVIDIA
  • Red Hat
  • Fidelity Investments
  • Intuit
  • OLX Brasil
  • Writesonic
  • Artium
  • Trolley
Bunny World Voxel Workspace

Short answer

Can I run Apex via my AI client?

Yes. You can send Apex code to Salesforce to run as an anonymous block. This lets you handle data updates and admin tasks through your agent. Here is how it works.

The outcomes

What you get done

Your agent handles the execution while you control the logic.

DATA

Clean up records

Your agent executes scripts to update fields or fix bulk data errors. You get the results of the execution immediately in your chat.

ADMIN

Manage settings

Run code to change organizational configurations or user permissions. It bypasses the need to click through complex setup menus.

TEST

Verify logic

Your agent runs small snippets of code against your live data to see how they behave. You see the success or error messages right away.

HUMAN

Review code

Your agent drafts the script based on your request, but you decide when to run it. You stay in the loop for each change made to the org.

The workflow

What your agent does when you request a script.

Your agent acts as the bridge between your natural language and the Salesforce runtime.

  1. Draft the script

    Your agent writes the specific Apex code needed to fulfill your request.

    sf_execute_apex
  2. Send to Salesforce

    Your agent sends the code block to your Salesforce instance for execution.

    sf_execute_apex
  3. Process execution

    Salesforce runs the code in the current context and returns the outcome.

    sf_execute_apex
  4. Report results

    Your agent reads the response from the system and tells you if the script worked or why it failed.

    sf_execute_apex

Vinkius Agentic Execution Platform

State the outcome. Agents take it from there.

You don't have to drive this run by hand. Inside the Vinkius Agentic Execution Platform, agents pick up the task above and carry it to the end: you set the limits, you watch the steps, you keep all decisions.

Run it in Vinkius

Agents carry the task to the end

Agents execute Salesforce tasks from end to end inside the Vinkius Agentic Execution Platform: set the outcome, and the steps run.

Take it to any compatible AI

One connection, any client

Same connection follows you to ChatGPT, Claude, Gemini and any other client you love. Switch whenever you want: your connection, your permissions and your record move with you.

Spaces

One Space per activity

A Space gathers the context, tools and tasks of one activity, so you coordinate several agents at once and follow each execution as it happens.

Limits

Autonomy inside limits you set

Permissions and spending limits are yours to define. Agents halt for your approval on anything sensitive, and you choose how far autonomy goes, step by step or end to end.

Record

All steps, on the record

Each action your agents take lands in a signed audit trail. Results are verified, mistakes are learned from, and an emergency stop is one click away.

Models

Included in your plan

A curated selection of AI models is included in your plan, and you can add your own through BYOK whenever you prefer.

Try it

Copy these to start.

Paste these into your chat to begin.

Starting points

Replace the object and field names with the ones used in your specific Salesforce org.

Salesforce Connector

You're all set. Choose your MCP client and follow the setup instructions.

Connector linkhttps://edge.vinkius.com/vk_preview_dXvoArPaPUkxjgPIyVRNAViK8yMiulYVKtQj5F9V/mcp

Claude Desktop

Follow the steps below to connect in seconds.

  1. 1In Claude Desktop, open Settings → Connectors.
  2. 2Click “Add custom connector” and paste the connector link above as the remote MCP server URL.
  3. 3Click Add and start a new chat, Salesforce capabilities are ready to use.
Configuration · claude_desktop_config.jsonCopy
{
  "mcpServers": {
    "salesforce-admin-metadata-mcp": {
      "url": "https://edge.vinkius.com/vk_preview_dXvoArPaPUkxjgPIyVRNAViK8yMiulYVKtQj5F9V/mcp"
    }
  }
}
Copy into chat04
  • 01

    Run an anonymous Apex script to update all Account names containing 'Test' to 'Legacy Account'.

  • 02

    Execute Apex to find all Contacts without an Email address and set their status to 'Invalid'.

  • 03

    Run this Apex snippet to delete all Task records created yesterday: [paste code here]

  • 04

    Write and run an Apex script to change the OwnerId of all Open Opportunities to a specific User ID.

  • Claude
  • ChatGPT
  • Cursor
  • VS Code
  • Windsurf
  • Claude Code
  • JetBrains
  • Cline

Start here

Connect Salesforce Admin & Metadata once, then ask.

Link your account once and your credentials stay encrypted on our side. You can then use any compatible client to run your scripts.

Connect Salesforce Admin & Metadata to your agent

FAQ

How the task behaves

  • 01

    Does your agent run code automatically?

    No. Your agent drafts the script, but you must review it and tell your agent to execute it.

  • 02

    Can your agent delete my data?

    Yes. If you ask your agent to run a script that includes a delete command, it will execute that command in Salesforce.

  • 03

    Can I run scheduled Apex jobs?

    No. This tool is only for running anonymous Apex blocks.

  • 04

    Does it work with the Developer Console?

    It provides an alternative to the Developer Console, allowing you to run code from your AI client instead.

  • 05

    Can your agent create new Apex classes?

    No. The tool is limited to executing anonymous Apex code.

  • More questions about Salesforce Admin & Metadata? The Connector page answers them. See everything the Salesforce Admin & Metadata Connector can do

Building with AI? Ship this whole workflow in your product.

Vinkius Connect is the connectivity layer for AI builders. All the capabilities used on this page, from Salesforce to thousands more, arrive through one SDK, already maintained for you. One Application, unlimited seats, each with their own connectors and credentials, isolated and never exposed to Vinkius. No OAuth flows to write, no tokens to store, no APIs to chase.

Explore Vinkius Connect

TypeScript · Python · Java · Go · C# · PHP · Rust

  • 01

    Your customers bring their own keys.

    Each user connects their own apps and keeps their own credentials. Vinkius only sees the identifier your backend sends.

  • 02

    Whole catalog, kept current.

    Salesforce plus thousands more, maintained and growing daily. No integrations to write, no token storage, no OAuth plumbing.

  • 03

    Any agent, any model.

    Capabilities land as framework-neutral objects, with adapters for OpenAI, Anthropic, Gemini, the Vercel AI SDK, LangChain and more.

Connect Salesforce to Claude, Cursor, ChatGPT & more

From idea to done

See what gets done when the agents take over the busywork

Each workflow on this page runs on the same platform. Connect your tools once, and your agents keep working in any AI you trust.