SAPSkills

SAP BTP Tutorial: Build Your First CAP App Step by Step

A hands-on SAP BTP tutorial. Start with BTP trial or free tier access, enable Cloud Foundry, scaffold a CAP app, deploy it, and verify. Real commands and code for beginners.

Updated June 14, 2026

This SAP BTP tutorial walks through building and deploying your first application on SAP BTP. By the end you will have BTP access, a CAP (Cloud Application Programming Model) service running locally, and that same service deployed to Cloud Foundry on BTP.

This is a beginner tutorial. It assumes basic command-line comfort and JavaScript knowledge, but no prior SAP experience. For the concepts behind each step, read What is SAP BTP? first.

Step 1: Set Up Your Account

  1. Sign up for SAP BTP access with your SAP Universal ID. For this tutorial, the 90-day BTP trial is the easiest starting point. For ongoing access, use Pay-As-You-Go or SAP BTP Enterprise Agreement with free tier service plans.
  2. Pick a provider and region (AWS, Azure, or GCP). Any region works for this tutorial.
  3. Wait for the account to provision. You will receive an email when it is ready.
  4. Open the SAP BTP cockpit at https://cockpit.<region>.hana.ondemand.com and sign in.

The cockpit is the web UI you will use for everything that is not code: accounts, entitlements, services, and deployments.

Step 2: Install the Tools

Install the command-line tools you need:

# Node.js 18+ (required for CAP)
node --version

# SAP Cloud Application Programming Model CLI
npm install -g @sap/cds-dk

# Cloud Foundry CLI (for deployment)
# macOS:  brew install cloudfoundry/tap/cf-cli
# Linux:  see cf CLI install docs
cf --version

# btp CLI (for account operations)
# Download from the SAP Help Portal "Using the btp CLI"
btp --version

Verify each command prints a version before moving on.

Step 3: Enable Cloud Foundry

In the BTP cockpit:

  1. Open your subaccount.
  2. Go to Environment > Cloud Foundry.
  3. Create a Cloud Foundry environment instance with a name and an org.
  4. Create a space (e.g. dev) inside the org. Apps run inside spaces.

Then log in with the cf CLI using the API endpoint shown in the cockpit:

cf api https://api.cf.<region>.hana.ondemand.com
cf login

Enter your SAP Universal ID credentials when prompted.

Step 4: Build a CAP App

Scaffold a CAP service and run it locally:

# Create a new CAP project
cds init bookshop
cd bookshop
npm install

# Define a simple data model
cat > db/schema.cds <<'EOF'
namespace my.bookshop;

entity Books {
  key ID : Integer;
  title  : String;
  stock  : Integer;
}
EOF

# Define a service that exposes the entity
cat > srv/service.cds <<'EOF'
using { my.bookshop as bookshop } from '../db/schema';

service CatalogService {
    @readonly entity Books as projection on bookshop.Books;
}
EOF

# Add sample data
mkdir -p db/data
cat > db/data/my.bookshop-Books.csv <<'EOF'
ID;title;stock
1;The Hobbit;12
2;Jane Eyre;10
3;Wuthering Heights;7
EOF

# Run it locally with SQLite
cds watch

Open http://localhost:4004/odata/v4/catalog/Books in a browser. You should see the three books. CAP has automatically generated an OData V4 service from your model and served it on an in-memory SQLite database.

Step 5: Deploy to BTP

Now deploy the same app to Cloud Foundry so it runs on BTP instead of your laptop.

First, add the deployment configuration. CAP generates it for you:

cds add mta

This creates an mta.yaml that describes the app as a Multi-Target Application. Then build and deploy:

# Install the MTA build tool
npm install -g mbt

# Build the deployable archive
mbt build

# Deploy to your Cloud Foundry space
cf deploy mta_archives/bookshop_*.mtar

The deploy command uploads the archive, creates the application, stages it, and starts it. When it finishes, the cf CLI prints the application URL. Open it and append /odata/v4/catalog/Books to confirm your service is live on BTP.

Step 6: Next Steps

From here you can extend the app in any direction:

  • Add a database. Bind an SAP HANA Cloud or PostgreSQL instance so data persists across restarts instead of using in-memory SQLite.
  • Add a UI. Generate a Fiori elements List Report on top of the OData service using SAP Fiori tools.
  • Secure it. Add authentication via the XSUAA or SAP Cloud Identity Services so only logged-in users can call the service.
  • Automate. Wire the deploy into a CI/CD pipeline using the SAP CI/CD service or GitHub Actions.

Using AI Assistants During the Tutorial

Each step above has places where a general AI assistant will guess wrong — CAP event handler signatures, the exact mta.yaml structure, or which CLI command to reach for. Installing the CAP skill gives the assistant accurate, current context so it can explain errors and suggest the next command instead of inventing one:

npx skills add secondsky/sap-skills --skill sap-cap-capire

With that skill loaded, you can ask the assistant to explain a cds error, draft an event handler, or review your mta.yaml, and get answers grounded in the real Capire reference.

Recap

You now have:

  • SAP BTP access through either the 90-day trial or a no-time-limit commercial account with free tier service plans.
  • A working CAP service running locally on SQLite.
  • The same service deployed to Cloud Foundry on BTP.

That is the full BTP development loop — model, serve, deploy — in under an hour. Everything else in BTP is a variation on this pattern with different services bound in.

Related Skills

Frequently Asked Questions

How do I start SAP BTP for free?

For a beginner tutorial, the simplest path is SAP's 90-day BTP trial. For ongoing no-time-limit access, use free tier service plans through a Pay-As-You-Go or SAP BTP Enterprise Agreement account.

What is the easiest first app to build on SAP BTP?

A CAP (Cloud Application Programming Model) service deployed to Cloud Foundry. CAP gives you a data model and OData service with minimal code, and Cloud Foundry is the default runtime for greenfield BTP apps. You can build and run it locally with SQLite before deploying.

Do I need the btp CLI for this tutorial?

You need it for account-level operations like enabling environments and entitlements. For deploying an app you use the cf (Cloud Foundry) CLI. Both are free command-line tools installed on your machine.

Can I run a CAP app locally without deploying to BTP?

Yes. CAP supports SQLite for local development, so you can build, run, and test your service entirely on your machine with the cds CLI. You only deploy to BTP Cloud Foundry (with SAP HANA Cloud) when you want a shared, production-like instance.

How long does a first BTP deployment take?

Once your account is set up and the CLIs are installed, scaffolding a CAP app and deploying it to Cloud Foundry typically takes 15-30 minutes for a first-timer, plus a few minutes of wait time for the platform to stage and start the app.

Explore all SAP BTP skills