How To Call APIs From SQL Server

With SQL Server 2025, Microsoft introduces a groundbreaking capability: native support for calling REST APIs directly from T-SQL using the new system stored procedure "sp_invoke_external_rest_endpoint".

This feature opens the door for integrating SQL Server more easily with external systems, cloud APIs, microservices, and more without needing CLR, SQL Agent jobs, or external scripting.

Sp_invoke_external_rest_endpoin is a built-in stored procedure introduced in SQL Server 2025 (v17.x) that allows SQL Server to make HTTP REST API calls directly from T-SQL and receive JSON responses.

This turns SQL Server into a more connected platform, enabling:

* Real-time integration with external services

* Triggering webhooks or third-party APIs

* Pushing data to Power BI, Microsoft Graph, or Azure Functions

* Querying external systems and merging results in T-SQL

Prerequisites -

* Before you can use sp_invoke_external_rest_endpoint, ensure:

* SQL Server 2025 is installed (17.x).

* You’re using a system administrator (sa) or a user with appropriate permissions.

* Your SQL Server is configured to allow outbound HTTPS traffic.

Security Considerations -

* Only HTTPS URLs are allowed.

* SQL Server must have internet access or DNS resolution to call public APIs.

* Ensure the token or key in headers is stored securely (e.g., in Azure Key Vault, or encrypted columns).

* Monitor network usage and rate limits of the APIs you're calling.

* Throttling, timeouts, and retries must be managed gracefully.

Comments

Popular posts from this blog

Standard Developer and Enterprise Developer edition in SQL Server 2025

How data is replicated from the Primary Replica to the Secondary Replica in a SQL Server Always On Availability Group

Accelerated Database Recovery (ADR) in SQL Server